# Http Monitor - get header without brackets

**URL:** <https://community.dynatrace.com/t/http-monitor-get-header-without-brackets/43069>\
**Category:** Synthetic Monitoring\
**Tags:** http-monitor, synthetic-monitoring\
**Created:** [December 7, 2023, 10:01am UTC](https://community.dynatrace.com/t/http-monitor-get-header-without-brackets/43069 "2023-12-07T10:01:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SabineR](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@SabineR](https://community.dynatrace.com/u/SabineR)\
**Post date:** [December 7, 2023, 10:01am UTC](https://community.dynatrace.com/t/http-monitor-get-header-without-brackets/43069/1 "2023-12-07T10:01:38Z")

</div>

Hello,

I’m building an HTTP monitor and in one HTTP request, I try to get the value of one header.

The problem is I receive the value with brackets.  
I tried to remove them with replace() or substring() but it is failing: UNKNOWN\_METHOD\_ERROR

How can I remove them?

Many thanks in advance for your answer,

Warm Regards,

Sabine

**Example:**

“responseHeaders”: [  
{  
“name”: “blabla”,  
“value”: “myvalue”  
},

**Post script:**

var resp = response.getHeaders().getAll(‘blabla’);  
api.setValue(“myValue”, resp);

**Result of myValue :** &nbsp;“[myvalue]”

---

<div class="post-metadata">

**Author:** ![AntonPineiro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antonpineiro/32/49_2.png) [@AntonPineiro](https://community.dynatrace.com/u/AntonPineiro)\
**Post date:** [December 7, 2023, 11:48am UTC](https://community.dynatrace.com/t/http-monitor-get-header-without-brackets/43069/2 "2023-12-07T11:48:59Z")

</div>

Hi,

Maybe this:

```javascript
var resp = response.getHeaders().getAll('blabla');
resp = resp.replace('[','')
resp = resp.replace(']','')
api.setValue("myValue", resp);

```

But you can explore other ways to remove a character from a string.

Best regards

---

<div class="post-metadata">

**Author:** ![SabineR](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@SabineR](https://community.dynatrace.com/u/SabineR)\
**Post date:** [December 7, 2023, 11:54am UTC](https://community.dynatrace.com/t/http-monitor-get-header-without-brackets/43069/3 "2023-12-07T11:54:36Z")

</div>

I tried it and it failed with error returned:&nbsp;Unknown method or invalid set of parameters.

Same with:

var resp1 = resp.substring(1, resp.length - 1);

---

<div class="post-metadata">

**Author:** ![AntonPineiro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antonpineiro/32/49_2.png) [@AntonPineiro](https://community.dynatrace.com/u/AntonPineiro)\
**Post date:** [December 7, 2023, 1:11pm UTC](https://community.dynatrace.com/t/http-monitor-get-header-without-brackets/43069/4 "2023-12-07T13:11:38Z")

</div>

Hi,

Maybe it because “resp” is not a string and it is an object.

My next actions would be:

- Checking type of “resp”. Maybe using “typeof”.
- Transform/extract string value.

Best regards

---

<div class="post-metadata">

**Author:** ![SabineR](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@SabineR](https://community.dynatrace.com/u/SabineR)\
**Post date:** [December 7, 2023, 1:59pm UTC](https://community.dynatrace.com/t/http-monitor-get-header-without-brackets/43069/5 "2023-12-07T13:59:21Z")

</div>

Yes, that was it:

I converted it in string, removed the 2 brackets, and now it works.

Thank you for your help!

Sabine

---------------------------------------------------------------

var resp = String(response.getHeaders().getAll(‘blabla’));  
var resp1 = resp.substring(1, resp.length - 1);  
api.setValue(“myvalue”, resp1);
