I am trying to add forwarding rule to the user's mailbox but it is not working asexpected - microsoft-graph-api

I am using graph API to add message rule which is forward a mail from user's inbox. Rule is getting added but mails are not forwarding to specified id.
Here are some details:
var data = {
"displayName": "From partner",
"sequence": 1,
"isEnabled": true,
"conditions": {
"isAutomaticForward": true
},
"actions": {
"forwardTo": [
{
"emailAddress": {
"name": "recipient name ",
"address": "email address"
}
}
],
"stopProcessingRules": true
}
}
axios.post("https://graph.microsoft.com/v1.0/users/{userId}/mailFolders/inbox/messageRules", data,
{
headers: {
"Authorization": "Bearer " + access_token
}
}
)
.then(response => {
console.log(response.data)
})
.catch(err => {
console.log(err.response)
})
Response is as expected but mails are not forwarding.

I tried the above payload, steps and it works for me!!
(1) Create a new rule using Graph API
POST https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messageRules
Content-type: application/json
{
"displayName": "From partner",
"sequence": 2,
"isAutomaticForward": true,
"actions": {
"forwardTo": [
{
"emailAddress": {
"name": "Alex Wilbur",
"address": "AlexW#contoso.onmicrosoft.com"
}
}
],
"stopProcessingRules": true
}
}
(2) Test whether the rule is working or not.
Result: It's working as expected
(3) Check that the above rule shows or not (as part of Outlook.office.com or Outlook UI's rule section)
Adding a snapshot that i captured from Outlook.office.com, mailbox settings!!

Related

Request sent from Swagger UI not resulting in Postman x-www-form-urlencoded response

I'm currently configuring a Swagger file to utilize OAuth to retrieve tokens from a site. For brevity, I have removed my schemes and most of my paths as those are fine.
{
"openapi": "3.0.2",
"info": {
"title": "swagger",
"version": "1.0.0",
"description": ""
},
"servers": [
{
"url": "url"
}
],
"paths": {
"/oauth_token.do": {
"post": {
"requestBody": {
"required": true,
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"OAuth": {
"type": "oauth2",
"flows": {
"password": {
"tokenUrl": "/oauth_token.do",
"refreshUrl": "/oauth_token.do",
"scopes": {
"useraccount": "utilize user account"
}
}
}
}
}
}
"security": [
{
"OAuth": ["useraccount"]
}
]
}
The endpoint for this API specifies that I should use x-www-form-urlencoded in the header as the Content-Type. When executing this request in Postman, it returns 200 with the desired response.
However, with https://editor.swagger.io I input the same postman request to get the fetch failed error with my Authorize button. To test for this, I created a custom path that specifies that the content should be x-www-form-urlencoded and this also fails.
So, what am I missing in this case? Any help would be appreciated.
I believe the issue was I did not fill out some portions I added on the response for path. Instead I opted to only leave description for the 200 response.
The main error I'm getting now is CORS related which is unrelated to the original question. I'll mark this answered for now.

Unable to get attributes value from inbound MMS "messageAdded" event's payload

const manager = Manager.getInstance()
manager.chatClient.on('messageAdded', payload => {
console.log('payload', payload) // it is correct
console.log('payload state attributes', payload.state.attributes)
})
Attributes are correct on chrome's console log
{
"body": "",
"media": null,
"attributes": {
"media": "https://api.twilio.com/2010-04-01/Accounts/ACfba1ba518fcc2321c11142f4041efa23/Messages/MM762e5ab98a2adde2970303db9ab6f4ba/Media/ME77ada464c9d50d6441501abf7bbd45c3",
"mediaType": "image/jpeg"
},
}
But with payload.state.attributes, the attributes changed to:
{
"proxied": true
[[Prototype]]: Object
}
Finally, figured it out after reading the Twilio flex "source code" from "node_module". If reason of "attributes" included from "updateReasons", then we can get the { media, mediaType } from "message.state.attributes".
I cannot find this mentioned anywhere from Twilio's documents.
manager.chatClient.on('messageUpdated', ({ message, updateReasons }) => {
console.log('message', message)
console.log('updateReasons', updateReasons)
})

ADP API Update Worker Information

I am trying to make updates within the ADP Worker API, though I keep getting "403: Invalid Scope" for the error. I am using this reference guide, specifically the People > Personal Information > Personal Profile > Contact > Add Home Phone section.
I can interact with the API through GET requests, though I am unable to POST. I am using the URL:
https://api.adp.com/events/hr/v1/worker.personal-communication.landline.add
Body Payload:
{
"events": [
{
"data": {
"eventContext": {
"worker": {
"associateOID": "exampleID123123"
}
},
"transform": {
"worker": {
"person": {
"communication": {
"landline": {
"areaDialing": "240",
"dialNumber": "4567896"
}
}
}
}
}
},
"links": []
}
]
}
Response:
{
"response": {
"responseCode": 403,
"methodCode": "POST",
"resourceUri": {
"href": "/events/hr/v1/worker.personal-communication.landline.add"
},
"serverRequestDateTime": "2021-09-09T18:26:44.607Z",
"applicationCode": {
"code": 403,
"typeCode": "error",
"message": "Invalid Scope"
},
"client_ip_adddress": "xxx.xx.xxx.xxxx",
"adp-correlationID": "xxxxxxxxx-xxxxxxxxxxx-xxxxxxxxxx"
}
}
Any suggestions? Thank you in advance!
After some searching, I believe the answer to my initial question is that we are required to contact our ADP representative to add the ability to hit the Event API. We only had access to the Worker API, which allowed successful calls previously.

Jira API: Add Comment Using Edit Endpoint

Jira has a an /edit endpoint which can be used to add a comment. There is an example in their documentation that suggests this input body to accomplish this:
{
"update": {
"comment": [
{
"add": {
"body": "It is time to finish this task"
}
}
]
}
}
I create the exact same input in my Java code:
private String createEditBody() {
JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
ObjectNode payload = jsonNodeFactory.objectNode();
ObjectNode update = payload.putObject("update");
ArrayNode comments = update.putArray("comment");
ObjectNode add = comments.addObject();
ObjectNode commentBody = add.putObject("add");
commentBody.put("body", "this is a test");
return payload.toString();
}
but when I send this PUT request I get an error saying that the "Operation value must be of type Atlassian Document Format"!
Checking the ADF format it says that "version", "type" and "content" are required for this format. So although their documentation example doesn't seem to be ADF format, I'm trying to guess the format and change it. Here's what I accomplished after modifying my code:
{
"update": {
"comment": [
{
"add": {
"version": 1,
"type": "paragraph",
"content": [
{
"body": "this is a test"
}
]
}
}
]
}
}
the add operation seems to be an ADF but now I get 500 (internal server error). Can you help me find the issue?
Note that the above example from Atlassian documentation is for "Jira Server Platform" but the instance I'm working with is "Jira Cloud Platform" although I think the behaviour should be the same for this endpoint.
after tinkering with the input body, I was able to form the right request body! This will work:
{
"update": {
"comment": [
{
"add": {
"body": {
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "this is a test"
}
]
}
]
}
}
}
]
}
}
The annoying things that I learned along the way:
Jira's documentation is WRONG!! Sending the request in their example will fail!!
after making a few changes, I was able to get 204 from the endpoint while still comment was not being posted! And I guessed that the format is not correct and kept digging! But don't know why Jira returns 204 when it fails!!!

Twilio autopilot redirect not working properly

Im having a problem in getting Autopilot redirect to work
After redirecting to my POST url it stops saying anything.
Below is my code:
{
"actions": [
{
"collect": {
"name": "password_reset_collect",
"questions": [
{
"question": "I will perform password reset to your account. Do you wish to continue?",
"name": "continue",
"type": "Twilio.YES_NO"
}
],
"on_complete": {
"redirect": "https://88fb4b1a.ngrok.io/Voice/Post"
}
}
},
{
"remember": {
"action_query": "password_reset"
}
}
]
}
and in my POST url it returns JSON result using return Content() as follows
var response = "{\"actions\": [{\"say\": {\"speech\": \"Thank you! Have a good day\" }},{\"listen\": true }]}";
return Content(response, "application/json");
result:
{
"actions": [
{
"say": {
"speech": "Thank you! Have a good day"
}
},
{
"listen": true
}
]
}
It never say what I specified in the on JSON and the call end
What am I doing wrong?
Twilio developer evangelist here.
I'd try putting Remember before Collect, as mentioned on the Actions docs page.

Resources