Base string incorrect for array type GET query string
See original GitHub issueIt seems that array type GET query strings aren’t quite supported.
e.g.
// request_data.data
{
filter: [ { attribute: 'updated_at', from: '2017-05-10 00:00:00' } ],
limit: 100,
page: 1
}
If you url encode this with something like qs, then you would get
filter%5B0%5D%5Battribute%5D=updated_at&filter%5B0%5D%5Bfrom%5D=2017-05-10%2000%3A00%3A00&limit=100&page=1
or in other words
filter[0][attribute]=updated_at&filter[0][from]=2017-05-10 00:00:00&limit=100&page=1
Which is a valid query string.
However, when the module is getting the Base string from this, the parameter string comes out like so
filter%3D%255Bobject%2520Object%255D%26filter%25255B0%25255D%25255Battribute%25255D%3Dupdated_at%26filter%25255B0%25255D%25255Bfrom%25255D%3D2017-05-10%252000%253A00%253A00%26limit%3D100%26page%3D1
Which decodes to
filter=[object Object]&filter[0][attribute]=updated_at&filter[0][from]=2017-05-10 00:00:00&limit=100&page=1
So as you can see it is nearly correct but the filter=[object Object]&
breaks it.
Is there some other way I should be passing in the filter array to make this work like qs?
If I omit the filter
parameter, then the signature works fine with the other params.
Hopefully I’ve explained myself well enough, thanks
If you are wondering, the filters in this format are expected by Magento’s REST API http://devdocs.magento.com/guides/m1x/api/rest/get_filters.html
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (7 by maintainers)
Top GitHub Comments
IMHO,
OAuth-1.0a
is a low level library and should not try to encode complex object; there’s many way to encode them and there’s no way to ensure the http client encoding will matchOAuth-1.0a
one. The solution would be to encode the data first, or let the http client encode it, and provide the encoded data toOAuth-1.0a
.OAuth-1.0a
would have to parse it like it parses the query string.An alternative would be to add a
data_encoder
option to override the default simple encoder.ps: probably
encoder
is not right word.for complicated object data, you should turn it to json string JSON.stringify(data) then send it as a string.