Skip to content

Instantly share code, notes, and snippets.

@dorreneb
Last active August 29, 2015 14:10
Show Gist options
  • Save dorreneb/979846cccc571950230b to your computer and use it in GitHub Desktop.
Save dorreneb/979846cccc571950230b to your computer and use it in GitHub Desktop.
OData Batching for O365 APIs Fiddler Trace

Two GETs in a single request

POST <url>/_api/v1.0/$batch HTTP/1.1
Host: <tenant>.sharepoint.com
Connection: keep-alive
Content-Length: 381
Accept: */*, application/json; odata=verbose
Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36
Authorization: Bearer <token>
Content-Type: multipart/mixed;boundary=batch_1234
Accept-Encoding: gzip,deflate
Accept-Language: en-US,en;q=0.8
Cookie: rtFa=4W6HJzVzXZnGVLI6zz7HPd7IP1tucvMv6iNtAQJcBv+NonmLPVZLWAap+3l33bBIzx4N2evZKP0KlSPQRZv94IP0V7qNRW+eMD2+n4x/TFDdfAkFWw7xbQ0gf9zHvRAopKMVEgVf1ITJtoW2qCfF1pDw7PpOJc1HxZ6EV8SHRGn9F9vK5T1+ULK+ZmHU7oUc6M4jBY7YyNUQHAWIo+vOJmIWi5EwTmq9bS+BWqbq4Eg9gLbT9Z7P8FcyySNYGto3uQhFRiu8y0k5eYMn92ir/dBv7LuDtpnXulM71+rRPo/DMg1EWrFc4rHL7RJs2nzAo3ecxHsNUwGnzB/MeEshv3BjM6kxBuGUbMuUDSTM6iPjZZdmR0PMVr2emkaYs5IpIAAAAA==
 
--batch_1234
Content-Type: application/http 
Content-Transfer-Encoding:binary
 
GET files/root HTTP/1.1
 
--batch_1234
Content-Type: application/http 
Content-Transfer-Encoding:binary
 
GET files/getByPath('Folder-A') HTTP/1.1
 
--batch_1234--
 
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Transfer-Encoding: chunked
Content-Type: multipart/mixed; boundary=batchresponse_7dac9dfe-39a7-4f32-8371-39a62061a825
Expires: Wed, 22 Oct 2014 19:17:08 GMT
Last-Modified: Thu, 06 Nov 2014 20:17:08 GMT
Server: Microsoft-IIS/7.5
X-SharePointHealthScore: 0
X-SP-SERVERSTATE: ReadOnly=0
ODATA-VERSION: 4.0
X-Download-Options: noopen
Content-Disposition: attachment
SPClientServiceRequestDuration: 1816
X-AspNet-Version: 4.0.30319
SPRequestGuid: db8ec99c-40b7-1000-a1f5-2e877772fb44
request-id: db8ec99c-40b7-1000-a1f5-2e877772fb44
X-FRAME-OPTIONS: SAMEORIGIN
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 16.0.0.3417
X-Content-Type-Options: nosniff
X-MS-InvokeApp: 1; RequireReadOnly
P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
Date: Thu, 06 Nov 2014 20:17:09 GMT
 
--batchresponse_3e9f3d79-a841-4de3-ac89-8d11e53089f0
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 200 OK
CONTENT-TYPE: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8

{"@odata.context":"<url>/_api/v1.0/$metadata#files/$entity","@odata.type":"#Microsoft.FileServices.Folder","@odata.id":"<url>/_api/v1.0/files/01SBTN2XF6Y2GOVW7725BZO354PWSELRRZ","@odata.editLink":"files/01SBTN2XF6Y2GOVW7725BZO354PWSELRRZ","createdBy":null,"eTag":null,"id":"01SBTN2XF6Y2GOVW7725BZO354PWSELRRZ","lastModifiedBy":null,"name":"/","parentReference":null,"size":0,"dateTimeCreated":"2014-07-17T12:29:58Z","dateTimeLastModified":"2014-10-27T20:08:41Z","type":"Folder","webUrl":"<url>/Documents","childCount":7}
--batchresponse_3e9f3d79-a841-4de3-ac89-8d11e53089f0
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 200 OK
CONTENT-TYPE: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
ETAG: "{55BB3068-0511-475D-A83B-ED32C3510768},1"

{"@odata.context":"<url>/_api/v1.0/$metadata#files/$entity","@odata.type":"#Microsoft.FileServices.Folder","@odata.id":"<url>/_api/v1.0/files/01SBTN2XDIGC5VKEIFLVD2QO7NGLBVCB3I","@odata.etag":"\"{55BB3068-0511-475D-A83B-ED32C3510768},1\"","@odata.editLink":"files/01SBTN2XDIGC5VKEIFLVD2QO7NGLBVCB3I","createdBy":{"application":null,"user":{"id":null,"displayName":"Su Api"}},"eTag":"\"{55BB3068-0511-475D-A83B-ED32C3510768},1\"","id":"01SBTN2XDIGC5VKEIFLVD2QO7NGLBVCB3I","lastModifiedBy":{"application":null,"user":{"id":null,"displayName":"Su Api"}},"name":"Folder-A","parentReference":{"driveId":"01JVHA7VKNB5WZV5UVG5AYWGWN5I4EGVFX","id":"01SBTN2XF6Y2GOVW7725BZO354PWSELRRZ","path":"/"},"size":0,"dateTimeCreated":"2014-09-22T23:51:41Z","dateTimeLastModified":"2014-09-23T17:58:26Z","type":"Folder","webUrl":"<url>/Documents/Folder-A","childCount":15}
--batchresponse_3e9f3d79-a841-4de3-ac89-8d11e53089f0--
 

GET and a DELETE

--batch_1234
Content-Type: application/http 
Content-Transfer-Encoding:binary
 
GET files/root HTTP/1.1
 
--batch_1234
Content-Type: application/http 
Content-Transfer-Encoding:binary
 
DELETE files/getByPath('Folder-B') HTTP/1.1
If-Match: *
 
--batch_1234--
 
--batchresponse_0404c302-7fcf-4f1c-8ee7-92f5c3dedfca
Content-Type: application/http
Content-Transfer-Encoding: binary
 
HTTP/1.1 200 OK
CONTENT-TYPE: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
 
{"@odata.context":"<url>/_api/v1.0/$metadata#files/$entity","@odata.type":"#Microsoft.FileServices.Folder","@odata.id":"<url>/_api/v1.0/files/01SBTN2XF6Y2GOVW7725BZO354PWSELRRZ","@odata.editLink":"files/01SBTN2XF6Y2GOVW7725BZO354PWSELRRZ","createdBy":null,"eTag":null,"id":"01SBTN2XF6Y2GOVW7725BZO354PWSELRRZ","lastModifiedBy":null,"name":"/","parentReference":null,"size":0,"dateTimeCreated":"2014-07-17T12:29:58Z","dateTimeLastModified":"2014-10-27T20:08:41Z","type":"Folder","webUrl":"<url>/Documents","childCount":7}
--batchresponse_0404c302-7fcf-4f1c-8ee7-92f5c3dedfca
Content-Type: application/http
Content-Transfer-Encoding: binary
 
HTTP/1.1 204 No Content
CONTENT-TYPE: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
 
 
--batchresponse_0404c302-7fcf-4f1c-8ee7-92f5c3dedfca--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment