Help

Re: Escape characters in json data in the API?

1769 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Jed_Davidow
6 - Interface Innovator
6 - Interface Innovator

Hello!

I am trying to upload a json string to a long text field in a table.

In this example, I want to populate the metaData column with:

{"json":"data"}

Here are various strings I have tried passing to curl via both the command line (-d ) and via STDIN:

{"records":[{"id": "reciTUyexGJBrfe3L","fields": {"metadata":"{"json":"data"}"}}]}
{"records":[{"id": "reciTUyexGJBrfe3L","fields": {"metadata":"{""json"":""data""}"}}]}
{"records":[{"id": "reciTUyexGJBrfe3L","fields": {"metadata":"{\"json\":\"data\"}"}}]}

All of these respond with:
{

"error":{"type":"INVALID_REQUEST_BODY","message":"Could not parse request body"}}

I tried searching these forums, and all of the issues with escape characters appear to be targeted to Formulas, and use the ", which is not working for me.

2 Replies 2

Are you stringifying your payload?

Are you able to update other fields with simpler values. For example uploading a simple text string without quotes?

Ugh. So I just realized I think the problem is with calling curl to do these updates.

The moronic API I have to use doesn’t have a PATCH method.

When I call a POST and pass the json-within-json it updates perfectly well, because this is passed through my API.

the problem is when I call the PATCH method with CURL, and it seems my json-to-string function is inserting double quotes (which should work, no?)

Anyway, so this is now a “how to format for curl on the command line” quesiton, which I still can’t figure out for this. I am trying to pass {“json”:“data”} in as the string to the Notes column in this record. If I replace that json element with a string, it’s fine.

curl -v -X PATCH https://<TABLE> -H <AUTH> -H "Content-Type: application/json" -d "{""records"":[{""id"": ""<ID>"",""fields"": {""lastTestResult"":""PASS"",""Notes"":""{\""json\"":\""data\""}""}}]}"