Hello,
I am trying to query the Orders endpoint using fetch in the backend of my third party app code.
This json input will return the data I need via the tool at this link .
{
"query": {
"filter" : "{\"buyerInfo.id\": \"9fa52159-7cc0-44a2-9ade-421c85100c90\"}"
}
}
But in my backend file, this code is returning a 400: Bad Request:
import {fetch} from 'wix-fetch';
export function CartActions_afterInsert(item, context) {
let url = "https://www.wixapis.com/stores/v2/orders/query";
let auth_code = <AUTH_CODE> //removed for the purpose of this post
let options = {
'method' : 'POST',
'headers' : {
'Content-Type': 'application/json',
'Authorization' : auth_code
},
'body' : JSON.stringigy({
"query": {
"filter" : "{\"buyerInfo.id\": \"9fa52159-7cc0-44a2-9ade-421c85100c90\"}"
}
})
}
fetch(url, options)
.then( (httpResponse) => { ... })
//...
}
Code in blue was added to solve the issue.