0

I am trying to execute curl post command through a bash script and I am facing lot of issues.

Here is the bash code I have:

#!/bin/bash url='http://slc760.us.oracle.com:10601/crmCommonApi/resources/latest' Content='Content-Type:application/vnd.oracle.adf.batch+json' user="sales_representative" payload='{ "parts": [{"id": "part1","path": "/latest/__ORACO__Inventory_c","operation": "create","payload": {"__ORACO__Product_Id2_c":204,"__ORACO__Facing_c":"20","__ORACO__Product_Id1_c":204,"__ORACO__Product_c": "Ghirardelli White Choco","__ORACO__ShelfStock_c":"10","__ORACO__Location_c" : "Aisle 2","Organization_Id___ORACO__Account_Inventory":"300100051199355"}},{"id": "part1","path": "/latest/__ORACO__Inventory_c","operation": "create","payload": {"__ORACO__Product_Id2_c":204,"__ORACO__Facing_c":"3","__ORACO__Product_Id1_c":204,"__ORACO__Product_c": "Ghirardelli White Chocolcate","__ORACO__ShelfStock_c":"4","__ORACO__Location_c" : "Aisle 2","Organization_Id___ORACO__Account_Inventory":"300100051199355"}}]}' curl -X POST -H "Content-Type:application/vnd.oracle.adf.batch+json" \ --data $payload \ $url \ --user $user 

When run throws bunch of errors:

curl: (6) Could not resolve host: "parts" curl: (3) [globbing] bad range specification in column 2 curl: (6) Could not resolve host: "part1","path" curl: (6) Could not resolve host: " curl: (6) Could not resolve host: "create","payload" curl: (3) [globbing] unmatched brace in column 1 curl: (6) Could not resolve host: "Ghirardelli curl: (6) Could not resolve host: White curl: (6) Could not resolve host: Choco","__ORACO__ShelfStock_c" curl: (7) Failed to connect to port 80: Connection refused curl: (6) Could not resolve host: "Aisle curl: (3) [globbing] unmatched close brace/bracket in column 66 curl: (6) Could not resolve host: "part1","path" curl: (6) Could not resolve host: " curl: (6) Could not resolve host: "create","payload" curl: (3) [globbing] unmatched brace in column 1 curl: (6) Could not resolve host: "Ghirardelli curl: (6) Could not resolve host: White curl: (6) Could not resolve host: Chocolcate","__ORACO__ShelfStock_c" curl: (7) Failed to connect to port 80: Connection refused curl: (6) Could not resolve host: "Aisle curl: (3) [globbing] unmatched close brace/bracket in column 66 org.codehaus.jackson.JsonParseException: Unexpected end-of-input: expected close marker for OBJECT (from [Source: weblogic.servlet.internal.ServletInputStreamImpl@10514b51; line: 1, column: 0]) 

When executed seperated through command-line the command seems to work but same when I try to execute it in CURL throws the above error.I know I am missing with relative to the quotes/syntax.

1
  • Please do not request that your questions are treated more urgently than other questions - people who answer here are volunteers, and they will answer at their leisure. Thanks! Commented Aug 6, 2015 at 11:55

2 Answers 2

1

Please try to change following line:

--data $payload 

to

--data '$payload' 
Sign up to request clarification or add additional context in comments.

Comments

1

Try putting double quotes on your payload:

curl -X POST -H "Content-Type:application/vnd.oracle.adf.batch+json" \ --data "$payload" \ $url \ --user $user 

That should work.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.