how to get the data content from response body?

Oct 2, 2012 at 1:21 AM



I made a OData batch request. I got the following response body in json format.

The data are in response body. But how can I get the data from the response body.

Is there any API I can use?

This must be a very common task, right?






Content-Type: application/http Content-Length: 1345 content-transfer-encoding: binary HTTP/1.1 200 OK Content-Type: application/json;charset=utf-8 Content-Length: 1258


{"__metadata": {"uri":"'980')","type":"sap.hba.apps.grcra-reuse.odata.grcra.UnusedRoleResultsType"},"SAPClient":"980","AccessControlBusProc":"PR00","AccessControlBusProcDesc":"Procure to Pay","NumberOfRoles":"17"},

{"__metadata": {"uri":"'980')","type":"sap.hba.apps.grcra-reuse.odata.grcra.UnusedRoleResultsType"},"SAPClient":"980","AccessControlBusProc":"FI00","AccessControlBusProcDesc":"Finance","NumberOfRoles":"7"},{"__metadata": {"uri":"'980')","type":"sap.hba.apps.grcra-reuse.odata.grcra.UnusedRoleResultsType"},"SAPClient":"980","AccessControlBusProc":"PM00","AccessControlBusProcDesc":"Plant Maintenance","NumberOfRoles":"3"},

{"__metadata": {"uri":"'980')","type":"sap.hba.apps.grcra-reuse.odata.grcra.UnusedRoleResultsType"},"SAPClient":"980","AccessControlBusProc":"MM00","AccessControlBusProcDesc":"Materials Management","NumberOfRoles":"1"}]}}


Oct 2, 2012 at 5:11 PM

Hi Zengy,

    When doing batch requests, datajs will have each response in the batch as an element of the __batchResponses array in the data parameter of the success callback funciton:

    function (data, response) {
       batchResponses = data.__batchResponses;
       var i, len;
       for(i = 0, len = batchResponses.length; i < len; i++){
           var data = batchResponses[i].data;
           // do something interesting with this individual response data.
    function error (err) { 
       // do something with the error 
    } , 


Alex Trigo.