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

**URL:** <https://community.postman.com/t/odata-use-an-odata-batch-run-get-then-delete-from-the-returned-results/49804>\
**Category:** Help Hub\
**Created:** [July 21, 2023, 9:51am UTC](https://community.postman.com/t/odata-use-an-odata-batch-run-get-then-delete-from-the-returned-results/49804 "2023-07-21T09:51:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pauljohndrennan](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@pauljohndrennan](https://community.postman.com/u/pauljohndrennan)\
**Post date:** [July 21, 2023, 9:51am UTC](https://community.postman.com/t/odata-use-an-odata-batch-run-get-then-delete-from-the-returned-results/49804/1 "2023-07-21T09:51:11Z")

</div>

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](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](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](https://XXXX-dev.corporate.ifs.com/FSMDEV/OData/$metadata#PAYMENT%22,%22value%22:%5B%7B%22created_by%22:%22METRIX%22,%22created_dttm%22:%222023-07-14T17:55:25.9100000%22,%22memo%22:%22INTEGRATION) 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](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.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [July 22, 2023, 11:11am UTC](https://community.postman.com/t/odata-use-an-odata-batch-run-get-then-delete-from-the-returned-results/49804/2 "2023-07-22T11:11:54Z")

</div>

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](https://learning.postman.com/docs/introduction/resources/)

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](https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-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](https://www.w3schools.com/) is a good place to start.
