ā02-09-2024 02:33 AM
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}"
Solved! Go to Solution.
ā02-10-2024 11:53 PM
Issue was solved using the next format
U"{\"data\":{\"consultationNumber\":\"" + s_parsejsonCaseN + U"\",\"clientId\":41,\"actionType\":\"INCOMING_CALL\"}}"
ā02-09-2024 06:20 AM
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
ā02-09-2024 06:23 AM
No, it does not accept this value
ā02-09-2024 07:27 AM
My bad, try: u"{\"data\":{\"consultationNumber\": \"00065\",\"clientId\": 41,\"actionType\": \"INCOMING_CALL\"}}"
ā02-09-2024 07:42 AM
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+
ā02-09-2024 07:57 AM
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\"}}]}}}]}"
ā02-09-2024 12:00 PM
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
ā02-10-2024 11:53 PM
Issue was solved using the next format
U"{\"data\":{\"consultationNumber\":\"" + s_parsejsonCaseN + U"\",\"clientId\":41,\"actionType\":\"INCOMING_CALL\"}}"
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide