ODATA - Use an OData batch, run GET then DELETE from the returned results

I’m trying to compose an OData batch to retrieve a set of results from table PAYMENT using request_id for the retrieval. From the returned results I want to extract the payment_id and add this to the URL for the delete as payment_id is the only allowed unique key in the delete URL.

I have the below OData batch:

–batch_ABC Content-Type: multipart/mixed; boundary=changesetPQR

–changesetPQR Content-Type: application/http Content-Transfer-Encoding: binary Content-ID: 1

GET https://XXXX-dev.corporate.ifs.com/FSMDEV/odata/payment?$filter=request_id eq ‘991’ HTTP/1.1 Content-Type: application/json

–changesetPQR Content-Type: application/http Content-Transfer-Encoding: binary Content-ID: 2

DELETE https://XXXX-dev.corporate.ifs.com/FSMDEV/odata/payment?$filter=request_id eq ‘991’ HTTP/1.1 Content-Type: application/json

–changesetPQR-- --batch_ABC—

Below are the results:

–batchresponse_fdffc443-4f7c-4be7-bbb6-4804476baa4d Content-Type: application/http Content-Transfer-Encoding: binary

HTTP/1.1 200 OK Content-Type: application/json; odata.metadata=minimal OData-Version: 4.0

{“@odata.context”:“https://XXXX-dev.corporate.ifs.com/FSMDEV/OData/$metadata#PAYMENT",“value”:[{“created_by”:“METRIX”,“created_dttm”:“2023-07-14T17:55:25.9100000”,“memo”:"INTEGRATION TEST”,“modified_by”:“METRIX”,“modified_dttm”:“2023-07-14T17:55:25.9100000”,“payment_amount”:“200.00”,“payment_card_cvv_mask”:“999”,“payment_card_expired”:“12/2024”,“payment_card_holder”:“Joe Bloggs”,“payment_card_no_mask”:“1234 5678 9101 1121”,“payment_card_type”:“VISA”,“payment_currency”:“TRY”,“payment_id”:15,“payment_method”:“CRDC”,“payment_ref”:“INTEGRATION”,“payment_status”:“INT”,“place_id”:“311”,“request_id”:“991”}]} --batchresponse_fdffc443-4f7c-4be7-bbb6-4804476baa4d Content-Type: application/http Content-Transfer-Encoding: binary

HTTP/1.1 404 Not Found Content-Type: application/json; odata.metadata=minimal OData-Version: 4.0

{“error”:{“code”:“”,“message”:“No HTTP resource was found that matches the request URI ‘https://XXXX-dev.corporate.ifs.com/FSMDEV/odata/payment?$filter=request_id eq ‘991’’.”}} --batchresponse_fdffc443-4f7c-4be7-bbb6-4804476baa4d–

Is the above possible?

Thank you in advance for any assistance.

I have played around a little bit with XPath as well but have been unsuccessful thus far, though it may just be my syntax that is out. I’m also looking into maybe using a different changeset, but I can’t quite join everything together.

It looks like your first request is returning JSON.

Can you please post your JSON response using the pre-formatted text option in the editor (so everything isn’t jumbled together).

We can then help you target the elements so you can save it as an environment or collection variable to be used in the next request.

Not sure why you mentionex XPath which is used with XML responses.

If you are new to Postman I would recommend the Postman training links which are located under “other resources” in the Learning Centre.

Other resources | Postman Learning Center

The “Galaxy API’s 101” course gets you used to sending requests and the GUI.

The “Galaxy Testing and Automation” gets you used to testing your responses and using variables, basic scripting, etc.

Also take a look at the following.

Postman JavaScript reference | using-environment-variables-in-scripts

Finally, Postman uses JavaScript under the hood, If you are going to be scripting, I would also recommend learning some JavaScript basics. WC3 schools is a good place to start.