Best way to embed JSON fields in POST requests for insert into PG using PostgREST

163 Views Asked by At

I am using PostgREST 7 and would like to do a simple insert into PostgreSQL. One of my fields is a JSON string and inserting it into the JSON body of the request breaks the parsing on PostgREST.

As an example using a simple JSON field, a request like:

curl -k -X POST --header Content-Type: application/json --header Accept: application/json --header Authorization: Bearer asdkfsldkfjsa;kfd;fdj -d {"imagenumber":"12345678", "imagename":"name", "imageversion":"1.0.4.344", "seriousVulnerabilityFound":"false", "report":"{scanResult:{3842483d3c94:{imageId:384241234594,imageSummary:{pass:true}}}}"

Is there a supported way to encode the JSON string field that will be decoded on PostgREST so that the field can be inserted into PG as a JSON column?

1

There are 1 best solutions below

0
On

The value in report is invalid json. Don't quote it and change it to a valid json:

{"report": {"scanResult":{"3842483d3c94":{"imageId":384241234594,"imageSummary":{"pass":true}}}}}