Hello,
I've got some problems regarding the consuming of Batch-Responses of OData. I've successful send out an OData Batch request via POST to $Batch;
The returned request however seems to be inaccessible to me in XSJS (this is just a shortened example!):
HTTP/1.1 200 OK Date: Tue, 17 Mar 2015 17:12:37 GMT Server: Apache/2.4.7 (Unix) OData-Version: 4.0 Content-Length: 455 Content-Type: multipart/mixed; boundary=batchresponse_idcdnaCy-dI6D-MOde-391O-3CTLb0Gk1Glf --batchresponse_idcdnaCy-dI6D-MOde-391O-3CTLb0Gk1Glf Content-Type: application/http Content-Transfer-Encoding: binary HTTP/1.1 400 Bad Request Content-Type: application/json;odata.metadata=minimal;charset=utf-8 Content-Length: 160 { "error" : { "code" : -1000, "message" : { "lang" : "en-us", "value" : "Property 'U_test' of 'Item' is invalid" } } } --batchresponse_idcdnaCy-dI6D-MOde-391O-3CTLb0Gk1Glf--
This seems a quite easy task, yet I cant access the content of the body, e.g.:
var client = new $.net.http.Client(); response = client.request(b1request, b1slDest).getResponse(); $.response.setBody(response.status + " \n-\n " + JSON.stringify(response.headers) + "\n-\n" + JSON.stringify(response.entities) + "\n-\n" + response.contentType + "\n-\n" + JSON.stringify(response.body));
and it returns:
200 - {"0":{"name":"~response_line","value":"HTTP/1.1 200 OK"},"1":{"name":"~server_protocol","value":"HTTP/1.1"},"2":{"name":"~status_code","value":"200"},"3":{"name":"~status_reason","value":"OK"},"4":{"name":"date","value":"Tue, 17 Mar 2015 17:29:16 GMT"},"5":{"name":"server","value":"Apache/2.4.7 (Unix)"},"6":{"name":"odata-version","value":"4.0"},"7":{"name":"content-length","value":"455"},"8":{"name":"content-type","value":"multipart/mixed; boundary=batchresponse_HR17MOOa-eebB-kJ1s-6HT8-h5yG3uEzbuwM"}} - {"0":{}} - multipart/mixed; boundary=batchresponse_HR17MOOa-eebB-kJ1s-6HT8-h5yG3uEzbuwM - undefined
So where is my body? How can I access the interesting part that is returned within the batch response? According to the XSJSDoc there are no more fields to access? (JSDoc: Class: WebResponse)
Best Regards,
KB