Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

CPO 3.0 Calling a REST API

I am trying to invoke a remote REST API that returns a JSON Object.

From Browser the API Call looks like this

http://ipam-dev/phpipam/api/?app_id=api&controller=sections&action=read&id=6

Returns

{"success":true,"data":{"id":"6","name":"Telford Subnets","description":"","masterSection":"0","permissions":"{\"4\":\"1\"}","strictMode":"1","subnetOrdering":null,"order":null,"editDate":null,"showVLAN":"0","showVRF":"0"}} 

When I try it to use the CPO activity Web HTTP Request it fails with the following error

Cannot send a content-body with this verb-type.

I think the issue here is the content type. The default value is application/xml; charset=utf-8 in the activity, I tried changing it to text, html and json but still did not work. I cannot leave the content type emty either in the activity.

Does anyone has any suggestion how to make a REST call from CPO using the activity Web HTTP Request

1 ACCEPTED SOLUTION

Accepted Solutions
Silver

CPO 3.0 Calling a REST API

Try changing GET to POST (in the CPO_REST-CALL-RQ.png screen).  Sending body content usually requires a POST not a GET.

3 REPLIES
Silver

CPO 3.0 Calling a REST API

Try changing GET to POST (in the CPO_REST-CALL-RQ.png screen).  Sending body content usually requires a POST not a GET.

New Member

CPO 3.0 Calling a REST API

Yes, POST did work...Thanks

Cisco Employee

CPO 3.0 Calling a REST API

Check out my blog series @

https://supportforums.cisco.com/community/netpro/data-center/intelligent_automation?view=blog

I write a ton on custom content development and have written on all kinds of web calls including JSON.

It looks like you just want to call that URL

http://ipam-dev/phpipam/api/?app_id=api&controller=sections&action=read&id=6

If that is the case, that should be your relative URL.

Your type should be a GET since you are using Query String methods in the URL call and then your content type can be application/json or application/text should be ok.

Your message you are sending should be blank as using a query string setup does not POST anything back to the webserver. Based on your URL, the web server pulls it's variables out of the query string.

If you were POSTING something it would be more of the vain of ....

http://myURL.com

as the relative URL

and then the message could be anything from XML to Query String to JSON.

Feel free to email me if you need more info.

--shaun

shaurobe@cisco.com

--Shaun Roberts shaurobe@cisco.com CIAC Adoption Pilot Engineering Lead
454
Views
0
Helpful
3
Replies
CreatePlease to create content