# \[KShare\] How to get the values of the HTTP header and Local Variables of the API requests?

**URL:** <https://forum.katalon.com/t/kshare-how-to-get-the-values-of-the-http-header-and-local-variables-of-the-api-requests/130512>\
**Category:** Kshare\
**Tags:** linh-nguyen, gatedknowledge, support, api-testing, katalon-studio\
**Created:** [May 7, 2024, 3:14pm UTC](https://forum.katalon.com/t/kshare-how-to-get-the-values-of-the-http-header-and-local-variables-of-the-api-requests/130512 "2024-05-07T15:14:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![support.squad](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/support.squad/32/23139_2.png) [@support.squad](https://forum.katalon.com/u/support.squad)\
**Post date:** [May 7, 2024, 3:14pm UTC](https://forum.katalon.com/t/kshare-how-to-get-the-values-of-the-http-header-and-local-variables-of-the-api-requests/130512/1 "2024-05-07T15:14:35Z")

</div>

![Forum thumbnail](https://europe1.discourse-cdn.com/katalon/original/3X/f/f/ffdbbc76e3e07eabe8084d6fe302d1092c0cf3ed.jpeg)

Hi all, 👋

For May, we are going to focus on API Testing tips, tricks, and tutorials to help you test better with the Katalon Platform. 🚀

* * *

Have you ever encountered difficulties attempting to obtain online service approach suggestions? Like the screenshot below…

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/8/8/887e7d69f910f4b4bc536b55a2841d8d178c61e5.jpeg)

If you do, then you should apply the syntax below:

```auto
import com.kms.katalon.core.testobject.RequestObject
import com.kms.katalon.core.testobject.ResponseObject

RequestObject requestObject = findTestObject('HTML_GetResponse')
ResponseObject response = WS.sendRequest(requestObject)
response.getResponseText()

```

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/9/0/904c6a94edfd5bee13c908344df2d67a24c7aa24.jpeg)

After fixing the request and response methods, we will address the primary question of API testing, which is: **how to obtain the properties of the HTTP header or Local Variables of the API requests**.

### HTTP Header

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/d/f/df1a8a947a5d0f0177cbe37644f0795529e6709b.jpeg)

In the HTTP Header, we have Content-Type and the API Key. Now, we will get the value of API Key with the scripts below:

```auto
RequestObject requestObject_UploadFile = findTestObject('Katalon_API_Demo_Requests/Post_Upload_File')
List headerProperties = requestObject_UploadFile.getHttpHeaderProperties()
def array = []
for(TestObjectProperty i: headerProperties) {
	array.add(i.getValue())
}
print array[1]

println GlobalVariable.apikey
GlobalVariable.apikey = array[1]
println GlobalVariable.apikey

```

You can refer to the video below to learn more on how it works:

Please also feel free to refer to the link bebelow for a sample project:

> **[Files](https://dev.azure.com/linhnguyen0979/_git/KShare_APITesting_GetHTTPHeaderValues)**

### Variables

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/3/2/32fdbd2f9f45371a89e774e46cd71ac101b09df7.jpeg)

```auto
import com.kms.katalon.core.testobject.RequestObject
RequestObject requestObject = findTestObject('Object Repository/Post_Upload_File')
Map<String, Object> variables = requestObject.getVariables()
print(variables)

```

* * *

If you find this article helpful, then don’t forget to leave us a like 👍 or a heart ❤ and share this article with your colleagues and teammates!

To see more [KShare](http://forum.katalon.com/c/product-insights/73) articles, simply navigate to the #support tag.

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [May 7, 2024, 3:16pm UTC](https://forum.katalon.com/t/kshare-how-to-get-the-values-of-the-http-header-and-local-variables-of-the-api-requests/130512/2 "2024-05-07T15:16:31Z")

</div>

Thank you the Product Support team (@support.squad) and **Linh Nguyen** (@linh.nguyen) for another informative article. We look forward to seeing more API-related articles from you!

| ![Linh Nguyen](https://europe1.discourse-cdn.com/katalon/original/3X/8/4/84e17374fb62b33f2d3ea89a16c9bf09f01aaf0b.png) |
| --- |
| **Linh Nguyen** (@linh.nguyen) - Product Support Manager at Katalon |
| Linh is the Product Support team Manager at Katalon. She spent many years working as an Automation Testing QA before joining Katalon Product Support as a technical support expert. Based on her experiences, she usually provides consumers with highly applicable solutions. She now manages her team with a user-centric approach to guarantee customers greater success with Katalon Products. |

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/katalon/original/3X/d/5/d55596ab02785a255798e87ede769734747b30c4.svg) [@system](https://forum.katalon.com/u/system)\
**Post date:** [May 7, 2025, 3:14pm UTC](https://forum.katalon.com/t/kshare-how-to-get-the-values-of-the-http-header-and-local-variables-of-the-api-requests/130512/3 "2025-05-07T15:14:59Z")

</div>

This topic was automatically closed after 365 days. New replies are no longer allowed.
