cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2983
Views
25
Helpful
12
Replies

UCCX - REST Call - POST JSON Body

I'm trying to create a REST Call on UCCX using POST method and having a JSON Body. Can someone please give me an example on how to do that? And where to put the JSON body as I cannot put it in a String. I already have the content type as "application/json".

12 Replies 12

Is the example at the end of this post what you're looking to do?

https://community.cisco.com/t5/contact-center/uccx-rest-json-post/td-p/3071095

I have checked the solution and actually the POST body I have is a JSON
format and it's a long one with many objects and parameters inside. So it
is hard to create a variable for each key value as provided in the link.

Please let me know if you have another solution.

Thanks in advance!

Hey

 

the restBody is a string that you format as JSON

 

"{'anis': "+ CallingNumber +",'dnis': "+ CalledNumber +",'callVar02': '"+ ci_Identifyer + "/" + ci_implementId +"','sessionId': "+ SessionId +"}"

Hope that helps

Please rate helpful posts and if applicable mark "Accept as a Solution".
Thanks, Thomas G. J.

Hi Thomas,

Actually the POST body I have is a JSON format and it's a long one with
many objects and parameters inside. So it is hard to create a variable for
each key value as you provided.

Please let me know if you have another solution.

Thanks in advance!

You only need to create varaible for the dynamic objects (If i understand you request))

 

"{'serverName': 'myServer.domain.com','dnis': "+ CalledNumber +",'staticObject1': 'staticValue1','staticObject2': 'staticValue2','sessionId': "+ SessionId +"}"

 And you can put it in directly in the body

 

Capture.PNG

Please rate helpful posts and if applicable mark "Accept as a Solution".
Thanks, Thomas G. J.

yess, you got my request right.

but whenever I press "Apply" btn, I get "Exception dialog" at the first
double quotes in my json block.

I don't know why I get this exception!!

As an alternative, if you can tolerate adding a JSON Object JAR to your platform you can make your life a whole lot easier and less error prone, as in attached example.

If you take it in smaller pieces is it then working

 

"{'serverName': 'myServer.domain.com'}"
"{'serverName': 'myServer.domain.com','serverId' : 1,'dnis': "+ CalledNumber +", 'queue': '"+ CSQ +"'}"

Object name has to be in single qoutes

For string variable in your json use '"+ variableName + "' (single and double qoute in beginning and double and single in the end)

For int variable in your json use "+ variableName + " (double qoute in beginning and double in the end)

Static values just single for string and for int only value

 

for debug purpose make and string variable and create the json body in a set step. Then you can see the output when it works

 

Hope that makes sense

Please rate helpful posts and if applicable mark "Accept as a Solution".
Thanks, Thomas G. J.

bsakizli
Level 1
Level 1

Hello,

I cannot get a successful response by the service with this method. It does not return a 200 response. The service asks for double quotes and we send it as single quotes on CCX side. But these methods you mentioned should work. The response from the service is as below. Do you have a suggestion?

Payload:

"{'uniqId':'string','logKey':0,'log':'string'}"

{ "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1", "title": "One or more validation errors occurred.", "status": 400, "traceId": "00-cf5517322d55a43c6bddc3b3d1fb6153-8085d6f3f5159c1e-00", "errors": { "$": [ "''' is an invalid start of a property name. Expected a '\"'. Path: $ | LineNumber: 1 | BytePositionInLine: 2." ] } }

But this way it works smoothly, this body is very complex.

Succsess Payload

"{\"uniqId\":\"string\",\"logKey\":0,\"log\":\"string\"}"

CCX - CCM Version: 11.6.2

 

More than likely it's the quotes that are causing the issue. I'll need to spin up a script where I'm parsing out double quotes for a POST request.

david

When we parse the double quotes, the readability of the content becomes very difficult. I don't understand how other friends above are sending json as POST...

I have the same issue. Did you find any solution?