When I send batch request made of calendar appointment request to Graph API, I seldom encounter a improper response from the API: some XML are injected as is in the JSON response.
This is impossible to unserialize, so I cannot know which appointment had issues, and it leaves no choice but to reiterate the same calendar appointments batch, which poses performance issue.
The request to batch API looks as follow (I intentionally hide information with *** in the post data below and did not show with ... the 3 others requests to calendar Graph API)
POST https://graph.microsoft.com/v1.0/$batch
Accept: application/json
Content-Type: application/json
{
"requests": [
{
"id": "33",
"method": "PATCH",
"url": "/me/calendars/***/events/***",
"body": {
"subject": "***",
"location": {
"displayname": "***"
},
"body": {
"content": "***"
},
"categories": ["***"],
"start": {
"dateTime": "2021-05-12 06:00:00",
"timeZone": "UTC"
},
"end": {
"dateTime": "2021-05-12 07:00:00",
"timeZone": "UTC"
},
"showAs": "free",
"isReminderOn": false,
"reminderMinutesBeforeStart": 0,
"singleValueExtendedProperties": [{
"id": "String {***} Name ***",
"value": "***"
}
]
},
"headers": {
"Content-Type": "application/json"
}
}, {
"id": "34",
...
}
]
}
This is what I seldom get (before and later on, the same id worked just fine)
{
"responses": [
{
"id": "33",
"status": 503,
"headers": {
"Content-Type": "text/html; charset=us-ascii"
},
"body":<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Service Unavailable</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Service Unavailable</h2>
<hr><p>HTTP Error 503. The service is unavailable.</p>
</BODY></HTML>
}, {
"id": "34",
"status": 200
...
}
]
}
Could you please investigate this issue and render a proper JSON response in any case, even if it fails with a 503 response?
Note: I reported this bug at https://github.com/microsoftgraph/microsoft-graph-docs/issues/12951 but none of the solution provided by the automated closing message was relevant.
I rather reported the bug to the right github repo https://github.com/microsoftgraph/msgraph-sdk-serviceissues/issues/93
Related
Running batch requests against most Microsoft Graph API endpoints returns a object with a value property like this:
{
"id": "2",
"status": 200,
"headers": {
"Cache-Control": "no-cache",
"x-ms-resource-unit": "1",
"OData-Version": "4.0",
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
},
"body": {
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,displayName,student,teacher)",
"value": [
{
"id": "ebe6297c-1f76-484e-9616-5e8e6be6098e",
"displayName": "Adele Vance"
}
]
}
},
However running a batch request against /education/user/{userId} gives me:
{
"id": "1",
"status": 200,
"headers": {
"Cache-Control": "no-cache",
"OData-Version": "4.0",
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
},
"body": {
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#education/users(id,displayName,student,teacher)/$entity",
"id": "ebe6297c-1f76-484e-9616-5e8e6be6098e",
"displayName": "Adele Vance"
}
}
Without any value property.
This looks like a bug. Not sure how to proceed.
Best regards,
Oskar
It depends on the endpoint you are calling in batch request.
For endpoints returning a collection, the batch response contains "value": [{..},..] in body...collection of objects.
For endpoints (like your endpoint GET /education/users/{id} that return single object, the batch response contains the object.
With Microsoft Graph API you can search your calendar events by issuing a request like it's documented here or like this:
POST /v1.0/search/query HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer <token>
Content-Type: application/json
Content-Length: 174
{
"requests": [
{
"entityTypes": [
"event"
],
"query": {
"queryString": "test"
},
"from": 0,
"size": 50
}
]
}
So, in my case, for the search query test, I have more than 200 events (recurring and single ones), and in the request payload we've sent to Microsoft Graph we have the size parameter which basically sets the limit of records to be returned by this call.
So, when I issue the request from above, I get something like this, but never more than 25 results. No matter how I modify the size parameter, it always returns 25 events, although there are hundreds.
HTTP/1.1 200 OK
Content-type: application/json
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#search",
"value": [
{
"#odata.type": "#microsoft.graph.searchResponse",
"searchTerms": [
"contoso"
],
"hitsContainers": [
{
"#odata.type": "#microsoft.graph.searchHitsContainer",
"hits": [
{
"#odata.type": "#microsoft.graph.searchHit",
"hitId": "AAMkADEwODY2NzllLTQ3MmEtNGRlMC05ZTUyLTE4ZDRhYmU1ZGM3NABGAAAAAAA3+iYQBnJnQabRVDelNhnzBwAejhWkAOAxQ6M4c1c9NwfrAAAAAAENAAAejhWkAOAxQ6M4c1c9NwfrAABbUZLJAAA=",
"rank": 1,
"summary": "this is a testing nothing more",
"resource": {
"#odata.type": "#microsoft.graph.event",
"end": {
"dateTime": "2020-06-16T04:15:00Z",
"timeZone": "UTC"
},
"hasAttachments": false,
"iCalUId": "040000008200E00074C5B7101A82E008000000007093FDD79B3AD60100000000000000001000000036DAA2262EB4E04DA27DA77985FB8251",
"isAllDay": false,
"sensitivity": "Normal",
"start": {
"dateTime": "2020-06-16T03:30:00Z",
"timeZone": "UTC"
},
"subject": "testing testing 123",
"type": "Single"
}
}
],
"total": 25,
"moreResultsAvailable": true
}
]
}
]
}
Furthermore, in the response you get the flag moreResultsAvailable which is in my case true, but other than that, I can't find a way to traverse between the results page, or do pagination of some sort.
What am I missing here, or in the docs?
So, when I issue the request from above, I get something like this,
but never more than 25 results. No matter how I modify the size
parameter, it always returns 25 events, although there are hundreds.
As per https://learn.microsoft.com/en-us/graph/api/resources/search-api-overview?view=graph-rest-1.0#page-search-results
The maximum results per page (size) is 25 for message and event.
For paging you just need to use the from property to specify the start of the page eg for the next page it would be
{
"requests": [
{
"entityTypes": [
"event"
],
"query": {
"queryString": "test"
},
"from": 25,
"size": 25
}
]
}
We are operating a TFS 2018 Update 2 in our enviroment.
We are sending the example json found here to our server and it is getting accepted successfully:
{
"properties": {
"sampleId": 7,
"customInfo": "Custom status information",
"startedDateTime": {
"$type": "System.DateTime",
"$value": "2017-09-19T14:50:26.7410146Z"
},
"weight": {
"$type": "System.Double",
"$value": 1.75
},
"bytes": {
"$type": "System.Byte[]",
"$value": "dGhpcyBpcyBzYW1wbGUgYmFzZTY0IGVuY29kZWQgc3RyaW5n"
},
"globalId": {
"$type": "System.Guid",
"$value": "1e788cb9-9d3d-4dc6-ac05-822092d17f90"
}
},
"state": "succeeded",
"description": "Sample status succeeded",
"context": {
"name": "sample-status-1",
"genre": "vsts-samples"
},
"targetUrl": "http://fabrikam-fiber-inc.com/CI/builds/1"
}
But the response doesn't look like in the documentation. Instead it looks like this:
{
"id": 6,
"state": "succeeded",
"description": "Sample status succeeded",
"context": {
"name": "sample-status-1",
"genre": "vsts-samples"
},
"creationDate": "2019-12-11T16:14:05.0574648Z",
"updatedDate": "2019-12-11T16:14:05.0574648Z",
"createdBy": {
"displayName": "...",
"url": "https://.../_apis/Identities/0b85e078-130d-4cb8-a450-17c5c7efccec",
"_links": {
"avatar": {
"href": "https://.../_api/_common/identityImage?id=0b85e078-130d-4cb8-a450-17c5c7efccec"
}
},
"id": "0b85e078-130d-4cb8-a450-17c5c7efccec",
"uniqueName": "...",
"imageUrl": "https://.../_api/_common/identityImage?id=0b85e078-130d-4cb8-a450-17c5c7efccec"
},
"targetUrl": "http://fabrikam-fiber-inc.com/CI/builds/1",
"_links": {
"self": {
"href": "https://.../_apis/git/repositories/35fe73eb-7af1-4bba-bf04-545611fcac1d/pullRequests/58/statuses/6"
},
"repository": {
"href": "https://.../_apis/git/repositories/35fe73eb-7af1-4bba-bf04-545611fcac1d"
}
}
}
The properties are gone. What could be wrong?
Could it be a somehow completely missleading documentation?
To troubleshoot your issue, please check the following items:
Check whether the Status updated on the pull request after running the POST request.
Press F12 in your browser, and send the POST request to check the statuses to see whether you can get properties in the response body.
Check your TFS edition by going to Administration Console -- Application Tier, or checking the About on the web portal. The issue can not be reproduced in TFS 2018.2 on our side.
We are trying the JSON batching of Microsoft Graph using this request:
{
"requests": [
{
"id": "1",
"method": "GET",
"url": "/me"
},
{
"id": "2",
"method": "GET",
"url": "/me/joinedTeams"
}
]
}
We are able to get a response from /me, but not for /me/joinedTeams:
{
"responses": [
{
"id": "1",
"status": 200,
"headers": {
"Cache-Control": "no-cache",
"OData-Version": "4.0",
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
},
"body": {
// valid response here
}
},
{
"id": "2",
"status": 400,
"body": {
"error": {
"code": "BadRequest",
"message": "Unsupported segment type. ODataQuery: users/35036c48-1e5a-4ca4-89f0-2d11c4cf8937/joinedTeams",
"innerError": {
"request-id": "a075c4f6-362a-469f-945b-5b46d96784a0",
"date": "2018-09-12T10:09:40"
}
}
}
}
]
}
Does batching not support the Teams APIs?
Teams Graph APIs are still in Beta but you're using the /1.0 endpoint. It should work fine on the /beta endpoint.
POST https://graph.microsoft.com/beta/$batch
Accept: application/json
Content-Type: application/json
{
"requests": [
{
"id": "1",
"method": "GET",
"url": "/me"
},
{
"id": "2",
"method": "GET",
"url": "/me/joinedTeams"
}
]
}
Trying to send an email through Microsoft Graph where another email from user mailbox is to be used as an attachment.
What I am doing is something similar to:
POST https://graph.microsoft.com/v1.0/me/sendMail HTTP/1.1
authorization: bearer {access_token}
content-type: application/json
content-length: 96
{
"message": {
"subject": "Meet for lunch?",
"body": {
"contentType": "Text",
"content": "The new cafeteria is open."
},
"toRecipients": [{
"emailAddress": {
"address": "garthf#a830edad9050849NDA1.onmicrosoft.com"
}
}],
"attachments": [
"#odata.type": "#Microsoft.OutlookServices.ItemAttachment",
"name": "menu.txt",
"item": {
"id": "some_id"
<!--This is the id of an existing email in User's inbox -->
}
]
},
"saveToSentItems": "false"
}
This returns with
Cannot process input of abstract type Microsoft.OutlookServices.Item
Can anyone help with suggestions?