# Getting JSON as string from web service

**URL:** <https://discourse.nodered.org/t/getting-json-as-string-from-web-service/57848>\
**Category:** General\
**Created:** [5 February 2022 21:34 UTC](https://discourse.nodered.org/t/getting-json-as-string-from-web-service/57848 "2022-02-05T21:34:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![quarfie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/quarfie/32/39697_2.png) [@quarfie](https://discourse.nodered.org/u/quarfie)\
**Post date:** [5 February 2022 21:34 UTC](https://discourse.nodered.org/t/getting-json-as-string-from-web-service/57848/1 "2022-02-05T21:34:31Z")

</div>

I am using HTTP Request node to make a call to a web service. The service returns JSON data and there is a `content-type` header with value `application/json; charset=utf-8`, but I have to add a `JSON` node after to convert it from a string to an object. Shouldn't that happen on its own?

I can see two possible causes:

This web service also returns a header `x-content-type-options` with value `no sniff`

This web service is returning formatted JSON (ie: with tabs and returns).

Would this be expected behaviour for one of those cases?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [5 February 2022 21:46 UTC](https://discourse.nodered.org/t/getting-json-as-string-from-web-service/57848/2 "2022-02-05T21:46:09Z")

</div>

> [@quarfie](#):
>
> I have to add a `JSON` node after to convert it from a string to an object. Shouldn't that happen on its own?

The http request node by default returns a utf-8 string, There is a setting at bottom of the http request config to output a JSON object.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [19 February 2022 21:46 UTC](https://discourse.nodered.org/t/getting-json-as-string-from-web-service/57848/3 "2022-02-19T21:46:35Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
