0

The curl command to try and post a JSON file with binary data

curl -X POST -H "Content-Type:application/json;charset=utf-8" -H "Accept: application/json" --data-ascii @filename.json http://localhost:3002/api/xyz -v -s

Gives an error 400

Unexpected token \u0011 in JSON at position 13

enter image description here

It appears the error is because data in json content variable is in binary containing 0x11 which JSON doesn't allow. How to encode it in utf-8 in cURL before sending this.

Here is the file in binary enter image description here

Rohan Sharma
  • 1,416
  • 2
  • 14
  • 19

1 Answers1

0

Try Encoding your binary data to base64,

Tibin
  • 612
  • 1
  • 8
  • 21