# Cannot set API header for Content-Type

**URL:** <https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425>\
**Category:** Web API's\
**Created:** [June 10, 2023, 11:23pm UTC](https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425 "2023-06-10T23:23:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![royrosemarin](https://avatars.discourse-cdn.com/v4/letter/r/a9adbd/32.png) [@royrosemarin](https://community.thunkable.com/u/royrosemarin)\
**Post date:** [June 10, 2023, 11:23pm UTC](https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425/1 "2023-06-10T23:23:09Z")

</div>

Please help. I’ve been spending the last hour on this seemingly trivial issue.  
 ![Screenshot 2023-06-11 at 00.16.11](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/0/e0d322a76c4402bf330468ae70d55a10c71eaf16.png)  
I am trying to set my API header to “Content-Type: application/json”. I have done it before and it was working, but when trying it now, my headers don’t get the Content-Type parameter. I’ve been printing it to debug, and it is just not part of the headers obtained on the server. Am i doing anything wrong, or is there a bug?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [June 11, 2023, 2:12am UTC](https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425/2 "2023-06-11T02:12:01Z")

</div>

Your header blocks are correct.

---

<div class="post-metadata">

**Author:** ![royrosemarin](https://avatars.discourse-cdn.com/v4/letter/r/a9adbd/32.png) [@royrosemarin](https://community.thunkable.com/u/royrosemarin)\
**Post date:** [June 11, 2023, 6:04am UTC](https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425/3 "2023-06-11T06:04:32Z")

</div>

Thank you.  
And yet when I run a curl request in my terminal: curl -X POST -H “Content-Type: application/json” -d … I get a good response, but when I use Thunkable as I showed above I keep getting “415 Unsupported Media Type: Did not attempt to load JSON data because the request Content-Type was not ‘application/json’.” In order to debug was printing all the headers obtained by the request, and indeed it does not get my headers on Thunkable.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [June 11, 2023, 7:57am UTC](https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425/4 "2023-06-11T07:57:27Z")

</div>

The headers aren’t really going to be displayed since they are an object. If you set the headers (temporarily) to a text string, you should see them when you debug the code. But as an object, the best you’re going to get is “[object]”.

I’m guessing there’s something else wrong with your blocks but you’ve hidden them either outside of the screenshot or with black pen so it’s not possible for me to know.

---

<div class="post-metadata">

**Author:** ![royrosemarin](https://avatars.discourse-cdn.com/v4/letter/r/a9adbd/32.png) [@royrosemarin](https://community.thunkable.com/u/royrosemarin)\
**Post date:** [June 11, 2023, 12:00pm UTC](https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425/5 "2023-06-11T12:00:35Z")

</div>

Hi, sorry I cannot provide much more data, but let me describe it in more detail: I deployed python code on a server (Google Cloud Functions) to intercept the request and I printed the headers there, not on Thunkable. The problem is when I call it with curl everything works perfectly, and I can even print the headers with: print(request.headers.get(‘Content-Type’)) and the body with print('Data: ', request.data). However, when I call it using Thunkable it seems that it cannot somehow parse my headers or the body parameters I guess, so it still prints the headers but w/o any Content-Type (which later produces the error I showed above), and also the data is not parsed correctly as I am getting an empty strong on the server. Yet, the function on my server is being triggered, so it triggers the correct HTTP url.

---

<div class="post-metadata">

**Author:** ![royrosemarin](https://avatars.discourse-cdn.com/v4/letter/r/a9adbd/32.png) [@royrosemarin](https://community.thunkable.com/u/royrosemarin)\
**Post date:** [June 11, 2023, 12:13pm UTC](https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425/6 "2023-06-11T12:13:18Z")

</div>

OK, I was reading few old posts about flask deployment, and I could see that other users had bugs when testing on the web version of Thunkable (here for example: [[Solved] how can I fix a 403 error using the WEB API - #9 by muneer](https://community.thunkable.com/t/solved-how-can-i-fix-a-403-error-using-the-web-api/2007685/9)). So, I moved to test on my mobile (Android Samsung, but in the post I referenced they also report that it worked on Iphone), and surprisingly - it worked great when I tested on Thunkable mobile app. So, in conclusion, seems like there is a problem when testing/calling API requests as web app. For now, I will call it solved, although I would appreciate if you could help us find a solution to test it also on the web.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [June 11, 2023, 2:21pm UTC](https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425/7 "2023-06-11T14:21:32Z")

</div>

I don’t work for Thunkable so I won’t be the one to find a solution but perhaps the Thunkable Staff will be able to. I know that many API calls don’t work in a web browser and instead must be run on a mobile device, as you mentioned.

CORS policy is one cause of this: [What is the CORS policy affecting my web app? | Thunkable Help Center](https://intercom.help/thunkable/en/articles/4515338-what-is-the-cors-policy-affecting-my-web-app)

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [June 11, 2023, 3:13pm UTC](https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425/8 "2023-06-11T15:13:58Z")

</div>

You are describing a CORS issue. It’s not a Thunkable thing, it’s your server. You’ll experience the same thing on bubble and even weweb

---

<div class="post-metadata">

**Author:** ![royrosemarin](https://avatars.discourse-cdn.com/v4/letter/r/a9adbd/32.png) [@royrosemarin](https://community.thunkable.com/u/royrosemarin)\
**Post date:** [June 11, 2023, 10:07pm UTC](https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425/9 "2023-06-11T22:07:30Z")

</div>

Thank you guys!

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:33pm UTC](https://community.thunkable.com/t/cannot-set-api-header-for-content-type/2460425/10 "2024-11-08T13:33:48Z")

</div>


