cancel
Showing results for 
Search instead for 
Did you mean: 

OData $batch 'GET' filter string

0 Kudos

Hello Experts,

I have a question regarding $batch 'GET' requests. I have found multiple posts which explain 'POST' $batch requests but they are not applicable to my problem with 'GET' requests.

I want to send multiple 'GET' requests to the OData service in one $batch request. My problem: the requests either abort with a 400 (Bad Request) or get through (Status 200, Debugger starts) but contain no filter string. Below you find my Coding.

Can you tell me if the url needs to have a special format so the request works?


//##################TESTING################\\

  var oModel = new ODataModel("/sap/opu/odata/sap/{SERVICE}");

  var aBatchOperations = [ ];

  aBatchOperations.push(oModel.createBatchOperation(

       "/BusinessPartnerSet?Type='Employee'&Name='Max Mustermann'",

       "GET")); //Status 200 but no filter

  aBatchOperations.push(oModel.createBatchOperation(

       "/BusinessPartnerSet?$filter=Type eq 'Employee' and PartnerNo eq '373'",

       "GET")); //Status 400

  oModel.addBatchReadOperations(aBatchOperations);

  oModel.setUseBatch(true);

  oModel.submitBatch(function(oData, oResponse) {

      //process response

  });

  //##################TESTING################//

Thanks in advance,

Matthias

Accepted Solutions (1)

Accepted Solutions (1)

former_member190939
Participant

Hi Matthias,

Your status 400 request should be like this:

aBatchOperations.push(oModel.createBatchOperation( 

"/BusinessPartnerSet?$filter=Type+eq+'Employee'+and+PartnerNo+eq+'373'",  

"GET")); //Status 400

Try this and let me know the result, thanks.

Seyed Ismail.

0 Kudos

Hello Seyed,

that was the solution. Thank you. I also changed my first request accordingly.

Can you explain to me why the plus is needed here?

Regards,

Matthias

former_member190939
Participant
0 Kudos

Hi Matthias,

I think SPACE is not expected on batch operations.

You can also check below link.

Thanks,

Seyed Ismail.

0 Kudos

Hello Seyed,

thanks again. I did not come across that blog. That explains it.

Regards,
Matthias

Answers (0)