0

Now I'm trying to use odata batch request in reference to the following things.

http://www.andrewconnell.com/blog/part-2-sharepoint-rest-api-batching-exploring-batch-requests-responses-and-changesets

https://gist.github.com/dorreneb/979846cccc571950230b

When I had sent batch request, came back empty response data. Following are examples of request and response acquired in Fiddler.

Please tell me why cannot get response data. I could get response data when I had sent request without batch so maybe Bearer token and URL are not wrong.

Request

POST (Site URL)/_api/v1.0/$batch HTTP/1.1
Authorization: Bearer eyJ0eXAiOiJKV...(token)
Accept: */*, application/json; odata=verbose
User-Agent: Mozilla/5.0 (Windows NT; Windows NT 6.1; ja-JP) WindowsPowerShell/4.0
Content-Type: multipart/mixed; boundary=batch_1234
Host: (Host)
Content-Length: 364
Connection: Keep-Alive

--batch_1234\n
Content-Type: application/http\n
Content-Transfer-Encoding: binary\n
\n
GET (Site URL)/_api/web/lists HTTP/1.1\n
\n
--batch_1234\n
Content-Type: application/http\n
Content-Transfer-Encoding: binary\n
\n
GET (Site URL)/_api/web/lists HTTP/1.1\n
\n
--batch_1234--

Response

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Transfer-Encoding: chunked
Content-Type: multipart/mixed; boundary=batchresponse_f9e3373b-ce82-4dab-8240-fcacf076a6b0
Expires: Wed, 15 Jul 2015 00:51:31 GMT
Last-Modified: Thu, 30 Jul 2015 00:51:31 GMT
Server: Microsoft-IIS/8.5
X-SharePointHealthScore: 0
X-SP-SERVERSTATE: ReadOnly=0
ODATA-VERSION: 4.0
X-Download-Options: noopen
Content-Disposition: attachment
SPClientServiceRequestDuration: 152
X-AspNet-Version: 4.0.30319
SPRequestGuid: e2e91e9d-30ac-2000-096a-4d37cee7e035
request-id: e2e91e9d-30ac-2000-096a-4d37cee7e035
X-FRAME-OPTIONS: SAMEORIGIN
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 16.0.0.4107
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, 30 Jul 2015 00:51:30 GMT

38
--batchresponse_f9e3373b-ce82-4dab-8240-fcacf076a6b0--

0
  • I would recommend this library called RestBatchExecutor, makes it a lot easier to do batch requests github.com/SteveCurran/sp-rest-batch-execution – Pantani Jul 30 '15 at 7:25
  • Thanks for your advice. Unfortunately I have to use batch request on native iOS/Android application so I cannot use Javascript Libary. – Hiroshi Yoshino Jul 30 '15 at 8:20
  • I found cause by comparing the sp-rest-bath-execution result and the failed. – Hiroshi Yoshino Aug 1 '15 at 0:13
  • I should have change line break to \r\n and remove '/v1.0'. – Hiroshi Yoshino Aug 1 '15 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.