6

I want to get all orders using REST Api. I am using this code but it's not returning any result.

Request:

$this->get('rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=entity_id');

Response: enter image description here

How to get all orders using REST Api?

asked Jan 18, 2017 at 13:08

2 Answers 2

4

Ideally next request must be valid to get all orders

$this->get('rest/V1/orders');

But you get error instead

{"message":"%fieldName is a required field.","parameters":{"fieldName":"searchCriteria"}}

Error occurred because request is processed by

\Magento\Sales\Api\OrderRepositoryInterface::getList(\Magento\Framework\Api\SearchCriteria $searchCriteria)

and $searchCriteria argument is required.

You can skip value for this parameter. Next request must be valid too.

$this->get('rest/V1/orders?searchCriteria');
answered Jan 18, 2017 at 13:33
1
  • $this->get('rest/V1/orders?searchCriteria=all'); return all feilds But i want to get only specific feilds. How can filters desire feild? Commented Apr 28, 2020 at 12:49
3

I got the solution for this. I passed my request like:

$this->get('rest/V1/orders?searchCriteria=entity_id');

and for getting all orders without any filter. Use below code:

$this->get('rest/V1/orders?searchCriteria');

answered Jan 18, 2017 at 13:20
2
  • I tried it using admin token. Is there is any way to use customer token? Commented Apr 6, 2017 at 9:54
  • @Jsparo30 curl -X POST "https:/yourdomain.test/rest/default/V1/integration/customer/token" \ -H "Content-Type: application/json" \ -d '{"username":"CustomerLogin", "password":"CustomerP@ssw"}' Commented Nov 10, 2023 at 10:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.