Hi,
I had opened a ticket which was flagged as solved, but it’s not solved.
I’m trying to use a snippet code i got from your developer website, to search conversations between two epochs. The codes runs without a problem on your platform, but when I use it in google scripts I get the response:
{"code":"invalid_query","message":"Query body must contain a query hash"}
I guess it is related to the JSON payload, though the string seems to be ok.
I was able to work with the API without any problem, when I don’t send a body, but I always get the error whenever I include a body.
I do have the ‘application/json’ in the code (the snipped below was copied directly) and I’ve tested removing the apostrophes from ‘content-type’ and I still get the same error.
I’m adding a screenshot of the data structure in my memory. All looks as it should.
Any clue?
const str = JSON.stringify({
query: {
value: {
{field: 'created_at', operator: '>', value: '1690081199'},
{field: 'created_at', operator: '<', value: '1690167601'}
],
operator: 'AND'
}
});
const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: 'Bearer XXXXXXXXXXXXXXXXXXXXXX'
},
body: str
};
const response = UrlFetchApp.fetch('https://api.intercom.io/conversations/search', options );