# JSON formatting on POST request

**URL:** <https://community.hubspot.com/t/json-formatting-on-post-request/83857>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [June 21, 2023, 4:05pm UTC](https://community.hubspot.com/t/json-formatting-on-post-request/83857 "2023-06-21T16:05:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MClubb](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@MClubb](https://community.hubspot.com/u/MClubb)\
**Post date:** [June 21, 2023, 4:05pm UTC](https://community.hubspot.com/t/json-formatting-on-post-request/83857/1 "2023-06-21T16:05:58Z")

</div>

Hi all,

I’ve been pulling what’s left of my hair out over this. I need to send a JSON payload that has nested values to a third party software but there seems to be no way to do it in the workflow.

I tried doing it using the Send webhook action but that only allows one level, no nesting. I tried a few other methods to put the nested value together as a string but Hubspot just injects backslashes into it so it becomes unusable.

I looked through the forums, and have contacted support. Everything seems to point to this thread, but I tried both solutions and neither worked.

[https://community.hubspot.com/t5/APIs-Integrations/Workflow-webhooks-with-nested-parameters/m-p/752643#M61178](https://community.hubspot.com/t5/APIs-Integrations/Workflow-webhooks-with-nested-parameters/m-p/752643#M61178)  
I added a code block using Python that used requests to make the post request and it still inserts backslashes. I tried running the code on my own compiler so I know it’s not an issue there.

I also tried using a Format data action but this had the same problem, I ended up with back slashes, and on top of that it adds this ‘“formula\_result\_output”:’ to the start of the string.  
There must be some way to send nested JSON, does anyone have a solution?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [June 22, 2023, 9:54am UTC](https://community.hubspot.com/t/json-formatting-on-post-request/83857/2 "2023-06-22T09:54:24Z")

</div>

Hello @MClubb

HubSpot does not support nested JSON in workflow actions. This is because JSON is a string, and strings in HubSpot are escaped by default. This means that any backslashes in the string will be converted to double backslashes, which will break the nested JSON. use a custom code block. In the custom code block, you can use the requests library to make a POST request to the third-party software. The requests library allows you to send nested JSON without having to escape backslashes.

```lia-code-sample
import requests

def send_nested_json(url, json_data):
 response = requests.post(url, json=json_data)
 return response

if __name__ == " __main__":
 url = "https://example.com/api/v1/my-endpoint"
 json_data = {
 "nested_field": {
 "key1": "value1",
 "key2": "value2"
 }
 }
 response = send_nested_json(url, json_data)
 print(response.content)

```

This code will send the nested JSON data to the third-party software. The requests library will automatically escape backslashes, so you don’t need to worry about that.
