Monday, April 28, 2014

CURL POST JSON Data from a File

Sometimes I need to POST JSON data to an API endpoint for testing that is too large to fit easily on the command line in the typical "{"id":1,"string":"something"}" format. Instead, it is much easier to just save the entire JSON structure to a file and then reference that file in the CURL.

For example, with the JSON data saved to temp.json:

curl -X POST -H 'content-type: application/json' -d @temp.json

It's as simple as that!

No comments:

Post a Comment