libwww-perl / HTTP-Message

The HTTP-Message distribution contains classes useful for representing the messages passed in HTTP style communication.

Home Page:https://metacpan.org/pod/HTTP::Message

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Batch HTTP requests

robhammond opened this issue · comments

I had trouble getting the multipart/mixed batch requests working with Google's APIs (a bunch of 400 bad request errors).

Figured out that the $r->add_part() function needs to add the following headers after the --batch_number block:

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

ie:

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

POST /analytics/v3/management/accounts/XXXXX/webproperties/UA-XXXXXX-X/profiles/XXXXXXXX/entityUserLinks
Content-Type: application/json

{"permissions":{"local":["READ_AND_ANALYZE"]},"userRef":{"email":"abc@example.com"}}

As per the spec here:
http://www.odata.org/documentation/odata-version-3-0/batch-processing/