I am trying to get a way to see if a message that i get using the Outlook Rest API using this url https://graph.microsoft.com/beta/me/messages('{messageid}') and seing if it is a reply. Normaly it would be from the Thread Id but the API doesn´t send one.
Is there anyway to see if the message is a reply?
API has one 'ConversationId' field. You can use that to group the messages.
{
...
"ConversationId": "AQQkADAwAT..."
...
}
This question has been answered here:
https://stackoverflow.com/a/60048538/3892957
Use GET https://graph.microsoft.com/v1.0/me/messages?$expand=SingleValueExtendedProperties($filter=(Id%20eq%20'Integer%200x1081'))
If a Message had been replied to you would see a result like
"singleValueExtendedProperties": [
{
"id": "Integer 0x1081",
"value": "102"
}
]
Related
We are integrating the MS Graph API's in our c# application. sending mail is working fine by following this article Send Mail Documentation. But I am facing an issue with ConversationIndex (Mainly Threads).
ConversationIndex of mail sent via API is different than recipients' replies to the same mail. Due to this it is unable to identify the threads.
This is the payload used to send mail. can anybody help me with any key or property I am missing while sending mail?
{
"message": {
"subject": "Meet for lunch?",
"body": {
"contentType": "Text",
"content": "The new cafeteria is open."
},
"toRecipients": [
{
"emailAddress": {
"address": "fannyd#contoso.onmicrosoft.com"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"address": "danas#contoso.onmicrosoft.com"
}
}
]
},
"saveToSentItems": "false"
}
Structure of Conversation Index
[reserved-1B] [timestamp-5B] [GUID-16B] [timestamp-5B][timestamp-5B]…[timestamp-5B]
<-------------Header Block----------------><-------------------Child Blocks------------------>
All messages part of the same conversation thread has the same 16-Bytes GUID.
5-Bytes [timestamp] in Header Block: System time when message was received converted into FILETIME format.
5-Bytes [timestamp] in Child Blocks: Child blocks are present only for Outlook messages, to indicate subsequent messages in a thread while keeping the header block attributes same. Every message reply to a conversation adds a [timestamp] at end to create a new conversationIndex.
Relative ordering of messages belonging to same conversation thread:
For all messages belonging to same GUID, SORT the messages by conversationIndex values.
Please refer to documentations here to understand better.
Tracking conversations
ConversationIndex property
I've tried to change MUC subject using ejabberd API but didn't work. I use Postman to work with the API
api : /api/change_room_option
request body :
{
"name": "testgroup",
"service": "conference.localhost",
"option": "subject",
"value": "BookNerds"
}
error : "400 Bad Request"
I've enabled change_room_option in my ejabberd.yaml and set allow_change_subj to true. Using this configuration and same request body format, I successfully change 'title' and 'description'.
Note : I ran another test using Adium and successfully change the subject. When I check in database, subject and subject_author have been updated. Do I need to set subject_author too in the request body? If yes - I don't think it's possible since change_room_option will only accept four parameters as stated here
I am trying to achieve send of mail via SendGrid API.
Following is the JSON I am sending as a body of the POST Method
{
"content" : [
{
"type" : "text\/plain",
"value" : "Hello, World!"
}
],
"personalizations" : [
{
"to" : [
{
"email" : "sahpranav1712#gmail.com"
}
],
"subject" : "Hello, World!"
}
],
"from" : {
"email" : "iospranav1712#gmail.com"
}
}
and following is the return that I am getting
{"message":"Bad Request","field":null,"help":null}
This piece of info doesn't help much.
The authorization is in place, and I believe correctly.
Perhaps, I might have missed some sort of settings in the SendGrid App
If it helps im using Objective-C.
Please help!!
I experienced the same issue and the problem was actually that all substitutions in the personalizations field need to be string values (see https://github.com/sendgrid/sendgrid-php/issues/264)
"personalizations": [{
"to": [{
"email": "mail#gmail.com"
}],
"substitutions": {
"{myFloatVal}": 16.5,
"{firstname}": "Thomas"
}
}]
What exactly is a 400 BAD REQUEST?
Why you are getting 400 BAD REQUEST from SendGrid one can only guess. 400 BAD REQUEST means oh we probably know what happened we are just not telling you.
This is a common 'error handling technique' where the developer catches the error and simply returns false, hiding any of the details or reasons for the failure.
Check for duplicate addresses.
One possible reason, as was in my case, one of the CC addresses was also the TO address. You see among many other things, SendGrid does not allow an email address to occur more than once in a send request, and if you happen to list an email recipient more than once in any of the TO,CC, or BCC lists SendGrid just sends back 400 BAD REQUEST.
Other Reasons
There are dozens of other poorly documented reason for 400 BAD REQUEST and I sincerely wish you luck in finding out why SendGrid rejected yours. One of the other answers here may help you.
Not setting [manager setRequestSerializer:[AFJSONRequestSerializer serializer]];
was the issue!!!
My experience usually is that the body has to be without any new lines (\n or \r for example), otherwise it will return a 400 error. When I clear up any new lines, it works, I usually use something like:
reg_replace('/\s\s+/', ' ', $message)
While this is an old issue, the following might be helpful for others.
If you are using dynamic templates, make sure that the Id is correct. The dashboard does not lend itself to easy copying of the template id, which means that one can easily include an extra space in front of the id.
By adding a space (or any other character for that matter) to the id of the template, SendGrid will simply reply with a Bad Request, without letting you know why.
Check email list too. If there is null or empty string in your BCC or to list Sendgrid will throw BAD Request.
I have successfully setup a facebook-messenger webhook. Until yesterday I was able to send and receive messages as well. But today, when I am sending one message from user, I am getting multiple calls at server webhook POST API. They never seem to stop.
Do all of those calls have the same content or are they different? You could log the exact message string that facebook sends to you and see what they include.
For example there's a message delivery callback that informs you that the user received the message. The JSON looks like this:
{'delivery': {'mids': ['mid.146174459xxx:30a42600a95exxxxx'], 'seq': 429, 'watermark': 146174459xxx}, 'recipient': {'id': xxxxxxxx}, 'sender': {'id': xxxxxx}}
Edit: It could also be the case that your are not confirming incoming calls with a http status 200. If facebook receives an error from your webhook the message will be sent multiple times.
Figured it out. I was sending response to every communication that came from facebook. So I ended up responding to ACK messages as well. In turn one more ACK came. Thats why it led to infinite loop.
In this page we can find different object structures for messages recieved:
text
{
"object":"page",
"entry":[
{
"id":PAGE_ID,
"time":1457764198246,
"messaging":[
{
"sender":{
"id":USER_ID
},
"recipient":{
"id":PAGE_ID
},
"timestamp":1457764197627,
"message":{
"mid":"mid.1457764197618:41d102a3e1ae206a38",
"seq":73,
"text":"hello, world!"
}
}
]
}
]
}
Message-Delivered callback
{
"object":"page",
"entry":[
{
"id":PAGE_ID,
"time":1458668856451,
"messaging":[
{
"sender":{
"id":USER_ID
},
"recipient":{
"id":PAGE_ID
},
"delivery":{
"mids":[
"mid.1458668856218:ed81099e15d3f4f233"
],
"watermark":1458668856253,
"seq":37
}
}
]
}
]
}
So, for differentiating we can refer to entry[0].messaging[0].message this exist only in user sent message. Callback or postbacks do not contain this part.
Check for this, before responding. If it exists, respond, otherwise dont.
My problem was similar but I was getting Multiple Message delivery posts. After a few hours of frustration, I realized that Message Delivered callback is called every time the message is delivered to EVERY DEVICE. So, if you are logged into both web and mobile app, the callback would be called twice.
When working with messenger of facebook you need to take in account two things after you send the message :
A) Message Delivery
B) Message Read
Since you are working with webhooks this will be trigger everytime one of the events happen (receive a message , deliver the message you sent , the user read the message). So if you activate for example message_deliveries in your webhook and you send a message as action , you will end up in a loop.
The proper way to handle this is in the base code. PHP example :
// Skipping delivery messages
if (!empty($message['delivery'])) {
#Do something here if you want
continue;
}
// Skipping read messages
if (!empty($message['read'])) {
#Do something here if you want
continue;
}
Hope it helps !
For a error case when calling some HTTP Rest service API, the response is as follows:
{
"statusCode": "400",
"error": "Bad Request",
"message": "Can not construct instance of java.math.BigDecimal from String value 'a': not a valid representation\n at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1#2f650e17; line: 1, column: 2] (through reference chain: com.foo.services.dto.request.ItemToUpdate[\"quantity\"])",
"validation": {
"source": "PAYLOAD",
"keys": ["key"]
},
"errorIdentifiers": [],
}
I am wondering if the message field in the response is appropriate. It does reveal certain level of implementation to the end user. Is this considered as
no particular problem at all
just a bad cosmetic issue that won't cause serious problem, just not readable to end user
potential security risk that definitely needs to be fixed
I think that you should only log the stacktrace on the server side. IMO it's technical hints (in addition, perhaps the end user even doesn't use Java to interact with your API) and the only thing that interests the end user of your API is that there is here a validation error within the provided data.
Another remark is that you use the status code and statusmessage within your response payload. I think that you don't need to duplicate this since it's already present in the response.
I would suggest an error message like that:
{
"messages": {
"quantity": "this must be a valid number"
}
}
I use a JSON structure for the field messages since there could be several validation errors within the provided data. Note that it's only a suggestion and you could extend this to your exact needs.
Hope it helps.
Thierry