Code 300, unsupported content type

Hello,
I am trying to build a chat application on a website with the zoom api.
When I try to post a message I get the following answer:

{"code":300,"message":"Unsupported Content Type"}

get requests work just fine. Also there are no issues with posting in postman.
This is my post request:

this.api
        .post('chat/users/me/messages/', body)
        .then((response) => console.log(response))

with the body being:

let body = JSON.stringify({
        message: event.detail[0].content,
        channel_id: this.curRoom.zoom_id
      })

And here I set my headers with Authentication:

this.api = axios.create({
        baseURL: baseURL,
        headers: {
          Authorization: `Bearer ${this.accessToken}`
        }
      })

As I said, get requests work, but if I try said post request
I always get code 300 in the answer and Error 415: “Unsupported Media Type” in the browser.
I would appreciate any help on that topic, since I am very new to working with APIs.

If you include a body (which is something that the HTTP POST method expects you to do), you should add the Content-Type header to indicate how to interpret the body. For Zoom APIs, you’ll typically use application/x-www-form-urlencoded; charset=utf-8 or application/json; charset=utf-8 depending on whether you format the body as a query string or as JSON. I don’t see an explicit content type specified, so maybe there is a default value being sent that doesn’t match the JSON you’re sending.

Hi, I already tried it with application/json as follows:

await this.api
        .post('chat/users/me/messages/', body, {
          headers: {
            'content-type': 'application/json'
          }
        })

In my browser it even says. that content-type:application/json is set.
I need it to work with json, but I don’t know what the issue is.

Have you checked the API Call Logs to compare what Zoom receives for your successful and failing calls? That might help quickly narrow down the differences without having to connect a web traffic proxy debugger like Fiddler to audit what’s being sent from your web server.

I have checked it right now. Apparently the zoom api does not support content-type: x-www-form-urlencoded . I have tried it in Postman and got Error 415. Also for some reason I cannot change the content-type in my code. If I try `let body = JSON.stringify({
message: event.detail[0].content,
to_channel: this.curRoom.zoom_id
})

  await this.api
    .post('chat/users/me/messages', body, {
      headers: {
        'content-type': 'application/json'
      }
    })
    .then((response) => console.log(response))`

, the zoom API just returns:

{
"endpoint": "https://api.zoom.us/v2/chat/users/me/messages",
"response_headers": [
"Set-Cookie: zm_aid=""; Domain=.zoom.us; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly"
],
"date_time": "2023-04-25 12:22:35",
"method": "POST",
"request_body": "N/A",
"response": {
"code": 300,
"message": "Unsupported Content Type"
},
"request_headers": [
"accept-encoding: gzip",
"accept: application/json, text/plain, */*",
"authorization: ******",
"connection: close",
"content-type: application/x-www-form-urlencoded",
"user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.58"
],
"request_params": [
],
"http_status": "415"
}.
As you can see, apparently the content-type is not being set correctly, and I do not know how to fix this.

Accidentally slipped into the code section ^^