Microsoft graph api returning incomplete json - microsoft-graph-api

Trying to make a call to the ms graph api to capture the ids of emails of a particular user, and it works fine for the first 1000 items, but when i try to send the next requests using the skip param, it sends back incomplete json.
for ref, here's my request GET "https://graph.microsoft.com/v1.0/users/<user-id>/messages?%24select=id&%24top=1000&%24skip=1081" (it's the autogenerated #odata.nextLink)

Related

Synchronization of outlook messages attributes (Flag, IsRead) and deletion status

According to this documentation Synchronize messages API users have ability to synchronize messages with pretty simple skipToken mechanics. And it works well for fetching new messages in folders.
But! What I'm also interested is how to sync flags and status like is message read or not.
For example I synced all messages from Inbox folder. After that user goes to his Outlook account and reads message and set some flag for this message.
How can I get this info? Should I resync all messages to get only those changes?
Also how I get notion about message removal? If some user deleted message from inbox, how I get to know which message was deleted without fetching all messages again?
You should use the Microsoft Graph API and move away from using the Outlook Rest API as it has been deemphasized with no more effort being put into the developer experience.
Use Microsoft Graph to synchronize and track changes by using the Delta query feature.
An initial sync call will happen with a Delta query. Make sure you select the properties you care about:
GET https://graph.microsoft.com/v1.0/me/mailfolders/AQMkADNkNAAAgEMAAAA/messages/delta?$select=subject,sender,isRead
Prefer: odata.maxpagesize=50
If the response has an #odata.nextlink in the response JSON object, GET that URL to the next page of results.
If the response has an #odata.deltaLink in the response JSON object, cache that URL until the next time you want to check for changes.

#odata:nextLink is sometimes not present when paginating through Outlook mail even if there is more mail

We are syncing user's Outlook accounts by paginating through the /me/messages endpoint in chronological order. Sometimes the API response will not include #odata:nextLink even if there are more messages.
We are just using the $top, $select, $skip, and $orderby parameters.
For example, one account was paginated up to about 25,000 emails and then there was no nextLink but the emails returned were over 6 months old so it was clear there were more emails since it is an active account. When I changed the $skip parameter to a higher number the API showed newer emails and then correctly returned a nextLink in the response.
Also we have the $top set to 100 but in the response missing a nextLink only 19 emails were returned (despite the emails being returned being over 6 months old and there being many newer emails), so there is some sort of gap in the messages being returned.
Calling the URL https://graph.microsoft.com/v1.0/me/messages?$top=100&$select=id,receivedDateTime,subject,bodyPreview,from,toRecipients,isDraft,sender&$skip=23352&$orderby=receivedDateTime asc returns 19 emails from 2017-06-16 and there is no nextLink in the response.
Calling the same URL but with $skip=24352 (skipping 1,000 ahead) returns 100 emails from 2017-06-17 to 2017-06-20 and has a nextLink in the response so it is clear there actually were more emails and a nextLink should have been present in the first response.
Please let me know if I am doing something wrong or if there is a way we can work around this, thank you!

Microsoft Graph get attachment data for mails and events

I understand that to use the /attachments API, an id of the event or message which has an attachment needs to be passed. Can attachment data for an event or message be obtained without this dependency? For example, when I'm making a call to /events API for a particular user, along with events data for that user, can I also get attachment data associated with the event?
I'm using client credentials flow.
This is possible by explicitly specifying that you'd like to include attachments the response body using the OData expand query option.
In your case, the request URI would look as follows: https://graph.microsoft.com/v1.0/me/events?$expand=attachments

Asana Webhooks API

So I have implemented the Asana Webhooks API as described in their documents. I can pass it a project ID and request a new webhook be created. The API successfully sends a authentication request to my application which returns the Security header as described in the Docs. Asana then returns the expected success response, outlining the newly created Webhooks unique ID.
Now if i take this ID and then query the Asana API to show me all configured webhook's on either the parent Workspace or the project resource directly it returns an empty data JSON Object or reports the resource doesn't exist, suggesting the Webhook Ive just created wasn't actually created, despite giving me the expected success response.
Also If I then make a change to a project it doesn't fire the webhook and I don't receive any events on my application.
Strangely everything was working on Friday but today (Monday) I'm experiencing these issues.
Any pointers would be good, Ive been working as the Docs suggest in terms of my request structure and am authenticating using a PAT, Ive even tried a newly created token.
Thanks,
Our webhooks use the handshake mechanism to make sure that it's possible to call you back, but there's always the possibility that subsequent requests can fail. Additionally (although we don't document this very well - there's an opportunity for us) we should immediately try to deliver a (probably) empty event after the handshake (it looks like {"events":[]}. This is kind of like a "second callback" that contains anything that has changed since you created the webhook.
If this fails - or if any subsequent request fails often enough - the webhook will get trashed. "Failure" in this context means returns HTTP response codes other that 200 or 204.
As for why you're having trouble querying the webhook itself, I wasn't able to repro the issue, so we'd have to dive deeper. It should be fine if you:
Specify the workspace
Optionally specify the resource
I tested this out, and it seemed fine. You also might want to directly query the webhook by id with the /webhooks/:id endpoint - note to use the id of the webhook returned by create, and not the id in the resource field.
If you created the webhook (specifically, your PAT or OAuth app was the one making the create request) you should see the information just fine. If you can get the webhook by id, you should see last_failure_at and last_failure_content fields which would tell you why the webhook was unable to make the delivery.
Finally, if you would like to contact us at api-support#asana.com and let them know more details (for instance, the ID of the webhook you're trying to look at) we can look at those fields from our side to see if we can identify what's going on.

JMeter- POST Json Request does it simulate or actually post data in UI?

I know it is a basic Question. Does a POST Json Request for update in User interface actually Post data in to database or just simulates the load for Post data without actually posting in database. But can someone please clarify
An HTTP Post request with the mandatory body (can be parameters, JSON, XML etc.), is intended to upload the data into server (upload images, Sign Up etc.), or to post data which server wants (to validate Sign in etc., not necessarily insert into the DB). So, it is basically how Server treats the data and the purpose.
If server puts the received data into the database, when performed the action using the browser, then the same operation expected when performed through JMeter also irrespective of the type of body data (JSON, XML etc). So, If you post the JSON data, it must be inserted into DB.
In DB, One thing to note is that server, either can directly dump the JSON data as JSON type itself or parse the JSON data and take the required values and store them in the Database. It depends on how the server is implemented.
So, how the server is implemented, it should behave the same way, whether you send the request from the browser or JMeter.
It depends on implementation. From JMeter's perspective API endpoint is yet another URL, JMeter sends a request to it, measures time between request and response and marks result as passed or failed depending whether HTTP Status Code is below 400 or not.
So it is up to you to check:
What does API endpoint actually do
What is correct request syntax (mandatory arguments, headers, cookies, URL parameters, whatever)
What is the expected result.
Optionally, what happens if "bad" request is being sent.
When designing a JMeter test always run it with 1-2 users and View Results Tree listener enabled to ensure that it does what it is supposed to be doing.
Coming back to your question: if HTTP response code is below 400, JMeter will mark sampler as successful, it won't check response body or database so I would recommend using the following test elements for confirmation:
JDBC PostProcessor - to check whether database was updated as a result of the request or not.
Response Assertion - to check that API response doesn't have errors, status code, variables, returned from the database, etc.

Resources