# Post header - SET HEADERS method

**URL:** https://community.thunkable.com/t/post-header-set-headers-method/1172691
**Category:** Questions about Thunkable X
**Created:** [March 17, 2021, 2:41pm UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691 "2021-03-17T14:41:34Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![umester2020mxtl](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/umester2020mxtl/32/99121_2.png) [@umester2020mxtl](https://community.thunkable.com/u/umester2020mxtl)
#### Post date: [March 17, 2021, 2:41pm UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691/1 "2021-03-17T14:41:35Z")

</div>

Hello, I’m Ulrich and new to thunkable and here comes my first question:

For getting data from an web api I need to place the Bearer token in the header of a POST.

Our Bearer token has a lifetime and i need to change it from time to time.  
Therefore I need a method to set it and found this inside the web\_Api ‘set headers’ method.

When I place the Bearer Token there I receive an 431.

When I use the same token just for trying directly inside the header within the design section it works fine.

So my question: why does the same thing in the design section work, while using the “set headers” methode inside the blocks does not?

Thank you 🙂

![2021-03-17_15h39_56](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/1/c11b47c5323e2b95c156a342623ac2c11b7a7c26.png)

---

<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: [March 17, 2021, 4:35pm UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691/2 "2021-03-17T16:35:26Z")

</div>

Good question. Can you share the blocks you used to attempt this?

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 17, 2021, 5:45pm UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691/3 "2021-03-17T17:45:16Z")

</div>

Most of API headers are constructed as JSON which your API could have this construction too.

You are passing it as string not JSON and therefore it fails.

---

<div class="post-metadata">

### Author: ![umester2020mxtl](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/umester2020mxtl/32/99121_2.png) [@umester2020mxtl](https://community.thunkable.com/u/umester2020mxtl)
#### Post date: [March 17, 2021, 6:02pm UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691/4 "2021-03-17T18:02:35Z")

</div>

Thank you muneer and jared 🖖  
I’ll try with json tomorrow and mark this thread as solved if it works.

---

<div class="post-metadata">

### Author: ![umester2020mxtl](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/umester2020mxtl/32/99121_2.png) [@umester2020mxtl](https://community.thunkable.com/u/umester2020mxtl)
#### Post date: [March 17, 2021, 11:54pm UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691/5 "2021-03-17T23:54:18Z")

</div>

no, sorry, I had a look. A bearer security token in the header is a string, not a json object (see [RFC6750](https://tools.ietf.org/html/rfc6750)).

So i need to pass a string to the header with the _set Web\_API 's header to_ method which does not work - while passing the same string within the design part to the header works.

So my question: is the **set Web\_API 's header to** working correct with strings as it should?

thanks 🙂

---

<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: [March 18, 2021, 1:56am UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691/6 "2021-03-18T01:56:30Z")

</div>

Header isn’t a string. It’s a [Json object](https://developer.mozilla.org/en-US/docs/Web/API/Request/headers) with key value pairs.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/f/7fbbb56afe6bd39e673653e0977284824a7c8e55.jpeg)  
You would use object blocks with key value pairs. Turn object into a Json. Attach that as the header blocks

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 18, 2021, 5:07am UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691/7 "2021-03-18T05:07:53Z")

</div>

You are mistaken, JSON is a formatted string by definition. Programming languages prefer to encapsulate it into an object which is a totally different subject.

---

<div class="post-metadata">

### Author: ![umester2020mxtl](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/umester2020mxtl/32/99121_2.png) [@umester2020mxtl](https://community.thunkable.com/u/umester2020mxtl)
#### Post date: [March 18, 2021, 10:01am UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691/8 "2021-03-18T10:01:11Z")

</div>

> Header isn’t a string.

I disagree. Bearer Header should be possible to be passed as a string. OAUTH with token in header is just one example.

google:  
Example `Authorization: Bearer ya29.AHES6ZRVmB7fkLtd1XTmq6mo0S1wqZZi3-Lh_s- ...`  
([HTTP headers and common query string parameters for JSON &nbsp;|&nbsp; Cloud Storage &nbsp;|&nbsp; Google Cloud](https://cloud.google.com/storage/docs/json_api/v1/parameters))

RFC6750:  
Example: Authorization: Bearer mF\_9.B5f-4.1JqM

I tried delivering in json format and our server rejected with _431 Request Header Fields Too Large_.

When sending “Authorization: Bearer mF\_9.B5f-4.1JqM…” as a string within of thunkables design page it works. And in thunkables design page you may of course provide a string 😉

---

<div class="post-metadata">

### Author: ![umester2020mxtl](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/umester2020mxtl/32/99121_2.png) [@umester2020mxtl](https://community.thunkable.com/u/umester2020mxtl)
#### Post date: [March 18, 2021, 11:57am UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691/9 "2021-03-18T11:57:59Z")

</div>

Solved my issue:

Sending as object works in this case without passing string.  
Problem was: the header _application-type_ in the design page gets overwritten (of course) when you use the **set Web\_API’s header to** method. Therefore you must provide at least both paramaters pairs: content-type + authorization.

Example for Authorization Bearer here:  
 ![2021-03-18_12h54_09](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/0/508dac601ab9f2037d7fda493667579e90a0f6df.png)

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 18, 2021, 12:01pm UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691/10 "2021-03-18T12:01:05Z")

</div>

Yes, now it’s correct. Most of the API services uses JSON to pass parameters.

Good job.

---

<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:25pm UTC](https://community.thunkable.com/t/post-header-set-headers-method/1172691/11 "2024-11-08T13:25:56Z")

</div>


