cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1048
Views
5
Helpful
3
Replies

Make rest Call

 

Im trying to Make REST call from uccx2 ( 2nd independent server) to uccx1 to know the NwaitingCalls from http://x.x.x.x:9080/realtime/VoiceIAQStats/

Im receiving a error 406 with either the content type or header wrong , Could you assist me what type would me admissible to use to accept and relay in UCCX server.

both server are version 11.6

Im currently using Content Type : text/xml;charset=UTF-8

Header : blank:

I could add in more info if required.

 

from postman it works just fine.

using variable string for body,response statuscode  and considering no username/password(blank) is required for this API request.

 

Any assistance would be highly appreciated.

Thanks

M Shankar

1 Accepted Solution

Accepted Solutions

Anthony Holloway
Cisco Employee
Cisco Employee

I have never done this before, but a quick test shows that Content-Type of application/json works in 12.0.

Also, just for fun, I tried port 9443 and HTTPS and it worked there too. So, either HTTP/9080 or HTTPS/9443 works.

 

uccx-rest-self-script.png

 

uccx-rest-self.png

 

Starting Value of REST

new String[] {
	// HTTP Request Section	
		// Index 0 - Request URL
		"http://contactcenter.netguys.local:9080/realtime/VoiceIAQStats",		
		// Index 1 - Basic Auth Username
		"",
		// Index 2 - Basic Auth Password
		"",
		// Index 3 - Content-Type Header
		"application/json",
		// Index 4 - Body Payload for POST/PUT Requests
		"",
	// HTTP Response Section
		// Index 5 - Response Body
		"",
		// Index 6 - Status Code
		"",
		// Index 7 - Status Detail
		""
}

Resulting Value of REST

new String[] {
	"http://contactcenter.netguys.local:9080/realtime/VoiceIAQStats",
	"",
	"",
	"application/json",
	"",
	U"[{\"id\":\"test\",\"operation\":\"UPDATE\",\"VoiceIAQStats\":{\"id\":1,\"esdId\":1,\"esdName\":\"test\",\"nResourcesLoggedIn\":1,\"nTotalContacts\":0,\"nHandledContacts\":0,\"nAbandonedContacts\":0,\"nDequeuedContacts\":0,\"avgTalkDuration\":0,\"longestTalkDuration\":0,\"avgWaitDuration\":0,\"longestWaitDuration\":0,\"longestCurrentlyWaitingDuration\":0,\"nAvailResources\":0,\"nInSessionResources\":0,\"nUnavailResources\":1,\"nUnavailResReasonsMap\":{\"32760\":1},\"nWorkResources\":0,\"nSelectedResources\":0,\"nAgentsAdded\":0,\"nAgentsRemoved\":0,\"nWaitingContacts\":0,\"nAverageHandlingTimeLowThreshold\":0.0,\"nAverageHandlingTimeHighThreshold\":0.0,\"nAverageWaitingTimeLowThreshold\":0.0,\"nAverageWaitingTimeHighThreshold\":0.0,\"nAbandonedCallsLowThreshold\":0,\"nAbandonedCallsHighThreshold\":0,\"nDequeuedCallsLowThreshold\":0,\"nDequeuedCallsHighThreshold\":0,\"nSLAPercentageLowThreshold\":0.0,\"nSLAPercentageHighThreshold\":50.0}}]",
	"200",
	"GET http://contactcenter.netguys.local:9080/realtime/VoiceIAQStats returned a response status of 200 OK"
}

Also, if you weren't aware, you can parse the returned body with the JSON steps like so:

 

uccx-rest-self-script-string-to-json-doc.png

uccx-rest-self-script-active-debug.png

 

This will mimic the Get Reporting Statistics step, in that it will return -1 if it cannot determine a good value.

View solution in original post

3 Replies 3

Anthony Holloway
Cisco Employee
Cisco Employee

I have never done this before, but a quick test shows that Content-Type of application/json works in 12.0.

Also, just for fun, I tried port 9443 and HTTPS and it worked there too. So, either HTTP/9080 or HTTPS/9443 works.

 

uccx-rest-self-script.png

 

uccx-rest-self.png

 

Starting Value of REST

new String[] {
	// HTTP Request Section	
		// Index 0 - Request URL
		"http://contactcenter.netguys.local:9080/realtime/VoiceIAQStats",		
		// Index 1 - Basic Auth Username
		"",
		// Index 2 - Basic Auth Password
		"",
		// Index 3 - Content-Type Header
		"application/json",
		// Index 4 - Body Payload for POST/PUT Requests
		"",
	// HTTP Response Section
		// Index 5 - Response Body
		"",
		// Index 6 - Status Code
		"",
		// Index 7 - Status Detail
		""
}

Resulting Value of REST

new String[] {
	"http://contactcenter.netguys.local:9080/realtime/VoiceIAQStats",
	"",
	"",
	"application/json",
	"",
	U"[{\"id\":\"test\",\"operation\":\"UPDATE\",\"VoiceIAQStats\":{\"id\":1,\"esdId\":1,\"esdName\":\"test\",\"nResourcesLoggedIn\":1,\"nTotalContacts\":0,\"nHandledContacts\":0,\"nAbandonedContacts\":0,\"nDequeuedContacts\":0,\"avgTalkDuration\":0,\"longestTalkDuration\":0,\"avgWaitDuration\":0,\"longestWaitDuration\":0,\"longestCurrentlyWaitingDuration\":0,\"nAvailResources\":0,\"nInSessionResources\":0,\"nUnavailResources\":1,\"nUnavailResReasonsMap\":{\"32760\":1},\"nWorkResources\":0,\"nSelectedResources\":0,\"nAgentsAdded\":0,\"nAgentsRemoved\":0,\"nWaitingContacts\":0,\"nAverageHandlingTimeLowThreshold\":0.0,\"nAverageHandlingTimeHighThreshold\":0.0,\"nAverageWaitingTimeLowThreshold\":0.0,\"nAverageWaitingTimeHighThreshold\":0.0,\"nAbandonedCallsLowThreshold\":0,\"nAbandonedCallsHighThreshold\":0,\"nDequeuedCallsLowThreshold\":0,\"nDequeuedCallsHighThreshold\":0,\"nSLAPercentageLowThreshold\":0.0,\"nSLAPercentageHighThreshold\":50.0}}]",
	"200",
	"GET http://contactcenter.netguys.local:9080/realtime/VoiceIAQStats returned a response status of 200 OK"
}

Also, if you weren't aware, you can parse the returned body with the JSON steps like so:

 

uccx-rest-self-script-string-to-json-doc.png

uccx-rest-self-script-active-debug.png

 

This will mimic the Get Reporting Statistics step, in that it will return -1 if it cannot determine a good value.

image.png

This is the make REST Ive done except i changed the content type after seeing your post.
yes im using the similar get JSON Doc Step to evaluate the message:

image.png

 

"$..VoiceIAQStats[?(@.id=='1')].nWaitingContact"

 

Do you think this read would work, but yeah the one you have tested with has a check for invalid commands, ill update those too.

 

Does yours work now?