cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1172
Views
0
Helpful
4
Replies

UCSD REST API Bad Request using curl

Sean Chandler
Cisco Employee
Cisco Employee

Does anyone have a working example of a curl call to UCS Director REST API.  Requests using the REST API browser seem to work but I have yet to replicate that on the command line.  No amount of escaping seems to work.  Neither GET nor POST etc etc.

Anyone?

curl -X GET -v -k -H 'X-Cloupia-Request-Key: 96E0734017714BF48408EC3C4A8672D3' 'https://192.168.241.252/app/api/rest?formatType=json&opName=userAPISubmitWorkflowServiceRequest&opData=\{param0:"InvokeCustTask",param1:\{"list":\[\{"name":"First Input","value":"Another"\},\{"name":"Second Input","value":"User"\}\]\},param2:-1\}'

...

> GET /app/api/rest?formatType=json&opName=userAPISubmitWorkflowServiceRequest&opData={param0:"InvokeCustTask",param1:{"list":[{"name":"First Input","value":"Another"},{"name":"Second Input","value":"User"}]},param2:-1} HTTP/1.1

...

< HTTP/1.1 400 Bad Request

< Transfer-Encoding: chunked

< Date: Fri, 11 May 2018 16:27:51 GMT

< Connection: close

* Server Web is not blacklisted

< Server: Web

1 Accepted Solution

Accepted Solutions

Orf Gelbrich
Cisco Employee
Cisco Employee

Are you replacing spaces with %20‘s and so on?

View solution in original post

4 Replies 4

Orf Gelbrich
Cisco Employee
Cisco Employee

Are you replacing spaces with %20‘s and so on?

Email reply didnt make it so here it is:

Started this message saying yes I escaped spaces etc but realized that “ need to become %22 etc.  So yeah it’s working now.  Also figured out the UCSM account name by looking at old manual runs and the output.

So for posterity here is the result (missing the other arguments to the workflow I have to add now that it is working):

curl -X POST -v --stderr - -k -x socks6h://localhost:8080 -H "X-Cloupia-Request-Key: 96E0734017714BF48408EC3C4A8672D3" 'https://192.168.242.252/app/api/rest?formatType=json&opName=userAPISubmitWorkflowServiceRequest&opData=\{%22param0%22:%22Cisco%20UCS%20Configure%20iSCSI%20Boot%20Info%22,%22param1%22:\{%22list%22:\[\{%22name%22:%22UCSM%20Account%22,%22value%22:%22INF...'

Thanks!

-s

Started this message saying yes I escaped spaces etc but realized that “ need to become %22 etc. So yeah it’s working now. Also figured out the UCSM account name by looking at old manual runs and the output.

So for posterity here is the result (missing the other arguments to the workflow I have to add now that it is working):

curl -X POST -v --stderr - -k -x socks6h://localhost:8080 -H "X-Cloupia-Request-Key: 96E0734017714BF48408EC3C4A8672D3" 'https://192.168.242.252/app/api/rest?formatType=json&opName=userAPISubmitWorkflowServiceRequest&opData=\{%22param0%22:%22Cisco%20UCS%20Configure%20iSCSI%20Boot%20Info%22,%22param1%22:\{%22list%22:\[\{%22name%22:%22UCSM%20Account%22,%22value%22:%22INFRA@admin%22\}\]\},%22param2%22:-1\}'

Thanks!

-s

Some times it is better tonnage the workflow a compound task and call a wrapper work flow tHat doe not have spaces and special chars.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Cisco UCS X-Series Energy Efficiency Offer