bash - Post a JSON file to a URL using Shell Script -


i writing shell script post json file url.

the header is:

content-type: application/json accept: application/json account-number: xxxxxxxx authorization: basic ew91cl91c2vyx25hbwu6cgfzc3dvcmq= 

the above json string saved .json file , curl command should process , desired response. use following command not process successfully:

curl -h "content-type: application/json" -x post -d "data=@$f" https://abcdef.com/test/example/v1/ 

$f has json file name.

i have following questions well:

  1. should header , json string in same json file? if header present in differnt file, should extension? , how process using curl command?
  2. is there specific handling should special characters {,",: etc?

you're not sending headers. don't believe there's option read desired headers file.

since you're scripting in bash, i'd store options in shell array readability:

curl_opts=(     -h "content-type: application/json"     -h "accept: application/json"     -h "account-number: xxxxxxxx"     -h "authorization: basic ew91cl91c2vyx25hbwu6cgfzc3dvcmq="     -x post      --data-binary "@$f" ) curl "${curl_opts[@]}" https://abcdef.com/test/example/v1/ 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -