cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2335
Views
0
Helpful
6
Replies

make REST call API with content type JSON

ravi.kumar1
Level 1
Level 1

has anyone got any any experience with JSON and make rest API step. is it possible to make a REST API call to webex which uses Oauth access token , i thought to pass the token in the header but it is not letting me leave the user id and password field blank, throws an error "Unable to parse expression, no formula entered".

Also am not sure how to pass the body, what i did is , i uploaded a text document like below in the repository

{
"title": "Project Unicorn - Sprint 0",
}

after this i executed a CREATe JSON step to convert this doc to JSON

then i used GET JSON step with JSON path as : "$.title" , not sure if it is correct

in the scripting guide it says that "Result data" should be a document variable, but body in the make REST call step has to be a string, do i need to convert the document to a string some way and how can i take care of the authentication when i have a token

token.jpg

6 Replies 6

Anthony Holloway
Cisco Employee
Cisco Employee

You can just put empty quotes for user/pass like this ""

For the body, leave it a string like this

u"{\"title\": \"Project Unicorn - Sprint 0\",}"

is u in the beginning a typo or it is needed and do we need a , at the end, before the curly bracket?

Thanks.

without u it gives me an error so i will take 'u' in the beginning  for an answer..

getting this error in the status

 

"Client response status: 412"

 

does it mean  that access to the target resource has been denied.

I'm not sure what is causing the 412, but I just tried it myself and it worked.

 

Variables

uccx-script-variable-webex-create-room.png

new String[] {
	// HTTP Request Section	
		// Index 0 - Request URL
		"https://webexapis.com/v1/rooms",		
		// Index 1 - Basic Auth Username
		"",		
		// Index 2 - Basic Auth Password
		"",		
		// Index 3 - Content-Type Header
		"application/json",
		// Index 4 - Authorization Header
		"Bearer ZmMxY2U0ZGMtZTA5NC00NmZiLThkZTItNTQ****",
		// Index 5 - Body Payload for POST/PUT Requests
		u"{\"title\": \"Project Unicorn - Sprint 0\"}",		
	// HTTP Response Section	
		// Index 6 - Response Body
		"",		
		// Index 7 - Status Code
		"",		
		// Index 8 - Status Detail
		""		
}

Script Steps

uccx-script-webex-create-room.png

Properties of Make REST Call step

uccx-make-rest-webex-create-room.png

Yes, the u prefix is important.

No, the comma is optional.  I just copied and pasted what you shared, which had the comma.  This works too:

u"{\"title\": \"Project Unicorn - Sprint 0\"}"
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: