cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Ask Me Anything - October 2020

321
Views
0
Helpful
6
Replies
Highlighted
Beginner

make REST call API with content type JSON

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
Highlighted
VIP Mentor

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\",}"
Highlighted

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

Thanks.

Highlighted

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

Highlighted

getting this error in the status

 

"Client response status: 412"

 

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

Highlighted

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

Highlighted

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\"}"
Content for Community-Ad