cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
396
Views
2
Helpful
7
Replies

UCCX REST POST method

Genadi
Level 1
Level 1

Hello everyone.

I have UCCX 12.5

I need to send rest api post method to external service. External service is expecting to receive  json in the next format:

{
"data":{
"consultationNumber": "00065",
"clientId": 41,
"actionType": "INCOMING_CALL"
}
}

value 00065 should be defined as string variable s_parsejsonCaseN

s_RESTBodyLog variable is used as Body of RESTP API CALL 

The value of s_RESTBodyLog is "{'data':{'consultationNumber': '"+s_parsejsonCaseN+",'clientId': 41,'actionType': INCOMING_CALL}}"

UNFORTINATLY i am receiving the next response from external server...
U"{\"message\":\"Unexpected token ' in JSON at position 1\",\"error\":\"Bad Request\",\"statusCode\":400}"

Genadi_0-1707474635942.png

 

 

1 Accepted Solution

Accepted Solutions

Issue was solved using the next format

U"{\"data\":{\"consultationNumber\":\"" + s_parsejsonCaseN + U"\",\"clientId\":41,\"actionType\":\"INCOMING_CALL\"}}"

View solution in original post

7 Replies 7

More than likely it's the quotes that are causing the issue. Can you hardcode a variable and test this?

{\"data\":{\"consultationNumber\": \"00065\",\"clientId\": 41,\"actionType\": \"INCOMING_CALL\"}}

david

No, it does not accept this value

Genadi_0-1707488594704.png

 

My bad, try: u"{\"data\":{\"consultationNumber\": \"00065\",\"clientId\": 41,\"actionType\": \"INCOMING_CALL\"}}"

It does not work with small u...but it works with

U"{\"data\":{\"consultationNumber\":\"00065\",\"clientId\":41,\"actionType\":\"INCOMING_CALL\"}}"

But i want to use variable instead of 000065 . I use U"{\"data\":{\"consultationNumber\":\"+ s_parsejsonCaseN +\",\"clientId\":41,\"actionType\":\"INCOMING_CALL\"}}"   the variable s_parsejsonCaseN is transfered to rest api as variabe +s_parsejsonCaseN+

 

Actually the replay that i get is 

U"{\"errors\":[{\"keyword\":\"WRONG_PARAM\",\"description\":\"INVALID_FORMAT\",\"descriptionInAllLanguages\":{\"error\":{\"target\":{\"data\":{\"consultationNumber\":\"+ s_parsejsonCaseN +\",\"clientId\":41,\"actionType\":\"INCOMING_CALL\"}},\"value\":{\"consultationNumber\":\"+ s_parsejsonCaseN +\",\"clientId\":41,\"actionType\":\"INCOMING_CALL\"},\"property\":\"data\",\"children\":[{\"target\":{\"consultationNumber\":\"+ s_parsejsonCaseN +\",\"clientId\":41,\"actionType\":\"INCOMING_CALL\"},\"value\":\"+ s_parsejsonCaseN +\",\"property\":\"consultationNumber\",\"children\":[],\"constraints\":{\"isNumberString\":\"consultationNumber must be a number string\"}}]}}}]}"

Ok, so we got past your first problem. Now you need to build your string and concatenate your variable. I'll try to find a script that does this to help you overcome what you're now facing.

david

Issue was solved using the next format

U"{\"data\":{\"consultationNumber\":\"" + s_parsejsonCaseN + U"\",\"clientId\":41,\"actionType\":\"INCOMING_CALL\"}}"