3
votes

I'm having a hard time fetching orders from Magento REST API when I use its GET filters like http://localhost/magento/api/rest/orders/?filter[1][attribute]=entity_id&filter[1][gt]=70&page=1&limit=100

It is giving a "error":[{"code":401,"message":"oauth_problem=signature_invalid"}]

When I try hitting the same API endpoint using a REST Client like Postman, I'm getting back the desired results JSON.

I suspect the square brackets in the filter query might be causing a problem in generating a Oauth signature. All the endpoints without GET filters are working fine. I'm using the Request node module to make the GET request with the oauth headers.

Is there any fix to avoid the signaturre invalid error?

3

3 Answers

2
votes

The problem was within the Request node module I was using to generate a OAuth signature.It didn't factor for square brackets in the URL. I modified the code in the module for including square brackets. Changing the OAuth signature generation method fixed it for me

0
votes

Since it took me a little while to figure out how to do this I figured I would pass on what I learned. My goal was to make a single request to the Magento’s REST API to return orders with specific order statuses. Looking through the GET filters documentation page wasn’t really helpful until I saw the very last line. Here is the request that I came up with that worked:

http://magentohost.com/api/rest/orders?filter[1][attribute]=status&filter[1][in][1]=pending&filter[1][in][2]=processing The above request will get you a list of all orders with a status of “pending” or “processing”.

Ref: http://magentoforce.com/2014/08/magento-rest-api-multiple-in-get-filters/