As you can see there are triple backslashes
Are those even ok?
Because standard frameworks on SUT-backend (SpringBoot & com.fasterxml.jackson) are going crazy about it…
If I send post requests via JSON.stringify, but without nested data, there is no problem at all…
To post JSON with nested data using httpx in Python:
Import the required modules:
python
Copy code
import json
import httpx
Define the nested data:
python
Copy code
data = {
‘name’: ‘John Doe’,
‘age’: 30,
‘address’: {
‘street’: ‘123 Main St’,
‘city’: ‘New York’,
‘state’: ‘NY’
}
}
Convert the data to JSON format:
python
Copy code
json_data = json.dumps(data)
Set the headers and content type:
python
Copy code
headers = {‘Content-Type’: ‘application/json’}
Make the POST request with the JSON data:
python
Copy code
response = httpx.post, data=json_data, headers=headers)
Check the response:
python
Copy code
if response.status_code == 200:
print(‘POST request successful’)
else:
print(f’POST request failed with status code: {response.status_code}')
Remember to replace with the actual URL of the API endpoint you want to send the POST request to.