# How to pass API Key when using POST/GET

**URL:** <https://forum.robotframework.org/t/how-to-pass-api-key-when-using-post-get/1317>\
**Category:** RequestsLibrary\
**Created:** [10 February 2021 21:48 UTC](https://forum.robotframework.org/t/how-to-pass-api-key-when-using-post-get/1317 "2021-02-10T21:48:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beau-Sof](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@Beau-Sof](https://forum.robotframework.org/u/Beau-Sof)\
**Post date:** [10 February 2021 21:48 UTC](https://forum.robotframework.org/t/how-to-pass-api-key-when-using-post-get/1317/1 "2021-02-10T21:48:21Z")

</div>

Hello all,

I am currently running API automation and am required to pass my API Key as well.

I am thinking I need to add this to my header EX: header={“x-apikey” : ‘key’} But I have tried this in numerous ways and it has failed… I am also thinking this can be added to the request body…

can anyone assist please and thank you!

---

<div class="post-metadata">

**Author:** ![Tualtaim](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/tualtaim/32/546_2.png) [@Tualtaim](https://forum.robotframework.org/u/Tualtaim)\
**Post date:** [11 February 2021 08:45 UTC](https://forum.robotframework.org/t/how-to-pass-api-key-when-using-post-get/1317/2 "2021-02-11T08:45:25Z")

</div>

What library are you using? I recently did this with [Browser’s HTTP keyword](https://marketsquare.github.io/robotframework-browser/Browser.html#Http)

---

<div class="post-metadata">

**Author:** ![lucagiove](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/lucagiove/32/85_2.png) [@lucagiove](https://forum.robotframework.org/u/lucagiove)\
**Post date:** [15 February 2021 12:58 UTC](https://forum.robotframework.org/t/how-to-pass-api-key-when-using-post-get/1317/3 "2021-02-15T12:58:39Z")

</div>

With [RequestsLibrary](https://github.com/MarketSquare/robotframework-requests/) you can easily do that.  
In [this file you can find examples](https://github.com/MarketSquare/robotframework-requests/blob/master/atests/test_headers.robot) how to set headers once for all the requests executed on the same session or how to set headers only for a specific request.

---

<div class="post-metadata">

**Author:** ![Beau-Sof](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@Beau-Sof](https://forum.robotframework.org/u/Beau-Sof)\
**Post date:** [26 February 2021 16:14 UTC](https://forum.robotframework.org/t/how-to-pass-api-key-when-using-post-get/1317/4 "2021-02-26T16:14:12Z")

</div>

Hello… Sorry for late response. My Dev peeps went a different route and I am up and running… Thanks for the assist!

---

<div class="post-metadata">

**Author:** ![abinashbeura-eaton](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/abinashbeura-eaton/32/4025_2.png) [@abinashbeura-eaton](https://forum.robotframework.org/u/abinashbeura-eaton)\
**Post date:** [2 July 2024 04:45 UTC](https://forum.robotframework.org/t/how-to-pass-api-key-when-using-post-get/1317/5 "2024-07-02T04:45:17Z")

</div>

Hi, I’m also facing the same issue can you please help me on that

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [2 July 2024 04:49 UTC](https://forum.robotframework.org/t/how-to-pass-api-key-when-using-post-get/1317/6 "2024-07-02T04:49:13Z")

</div>

Hi Abinashbeura,

It’s probably best to start a new topic rather than trying to revive this 3 year old topic.

Also when you do, to get the best help, mention the library you are using what you’ve tried and what errors you are getting. the more information you give about the issue your facing the better the help you’ll get.

Dave.
