cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Batch Request Error

jibin_joy
Contributor
5,043

Hi friends,

   Getting Error In Batch request "The Data Service Request could not understood due to  malformed syntax"..

plz check attachment for more information ( Batch Request and its response  )

Thanks in Advance

Best Regards

Jibin Joy

View Entire Topic
former_member182048
Active Contributor

Hi Jibin

I just did a successful $batch request similar to yours, same headers with 2 GET operations

--batch
Content-Type: application/http
Content-Transfer-Encoding: binary

GET Contacts('BARG') HTTP/1.1


--batch
Content-Type: application/http
Content-Transfer-Encoding: binary

GET Contacts('BARS') HTTP/1.1


--batch

I believe that you need to ensure proper spacing between the GET operation and the following -batch

eg. above has three carriage returns after the GET, if i remove one i get

"The Data Services Request could not be understood due to malformed syntax"

when trying to POST

Hope it helps

JSP

jibin_joy
Contributor
0 Likes

Hi John, 

    Thanks for advice .

Can i known why we required " three carriage returns after GET" ...whether it is Bug or some format for Batch Request .

Regards

Jibin Joy

former_member182048
Active Contributor
0 Likes

Hi Jibin

Its not a bug its how multipart calls work.

You may want to look at RFC 2046, it discusses in detail how multipart boundary rules work, in particular the use of CRLF's for padding between sections.  Its the same for emails, images etc

I would suggest however that you should be using one of the many OData Client Libraries which abstract the need to know such details.

There is a lot more to $batch calls, a library like datajs makes it easy for developers.

eg.

--batch_70a5-6b9b-ac07

Content-Type: multipart/mixed; boundary=changeset_0cf1-85e5-364b

--changeset_0cf1-85e5-364b

Content-Type: application/http

Content-Transfer-Encoding: binary

POST Contacts HTTP/1.1

Content-Length: 154

Content-Type: application/json

Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1

DataServiceVersion: 1.0

MaxDataServiceVersion: 2.0

{"Email":"","Mimetype":"","Avatar":"","PhoneMobile":"","PhoneOffice":"","PhoneHome":"","CatchPhrase":"Doh","LastName":"Simpson","FirstName":"Homer","Handle":""}

--changeset_0cf1-85e5-364b

Content-Type: application/http

Content-Transfer-Encoding: binary

POST Contacts HTTP/1.1

Content-Length: 154

Content-Type: application/json

Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1

DataServiceVersion: 1.0

MaxDataServiceVersion: 2.0

{"Email":"","Mimetype":"","Avatar":"","PhoneMobile":"","PhoneOffice":"","PhoneHome":"","CatchPhrase":"Doh","LastName":"Si","FirstName":"FFF","Handle":""}

--changeset_0cf1-85e5-364b--

--batch_70a5-6b9b-ac07--

Cheers

JSP

jibin_joy
Contributor
0 Likes

Thanks for Information