I am trying to write the following curl post function with basic authentication in vanilla javascript.
curl -X POST \
https://api.livechatinc.com/v3.3/agent/action/list_chats \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <your_access_token>' \
-d '{}'
This is my code in javascript.
(async () => {
const rawResponse = await fetch(url, {
method: 'POST',
headers: {
'Content-Type' : 'application/json',
'Authorization': 'Basic ' + btoa(username+":"+password)
},
body: {
"filters.group_ids" : "1",
"limit" : 1
}
});
const content = await rawResponse.json();
console.log(content);
})();
I keep getting this error "error: message: "Invalid message" type: "validation""
The curl method works perfectly in postman. I have read the documentation about this error and tried removing the content type header. It did not work. Any help is appreciated.