04-05-2020 07:40 PM
Hi Everyone,
Trying to verify passing of data and extraction of value using local test json-server before testing with CRM
JSON Path expression - "$..first_name" looks correct, validated online with jsonpath.com and Postman's JSONpath Visualizer. Tried with these other Path expressions - "$.*.first_name" & "$.[0].first_name" that show results in Postman but they do not work in CCX.
json file >
{"employees": {"first_name": "John","last_name": "Doe"}}
'Get JSON Document Data' step does not seem to like the data format in received Response Body from the json-server. Testing the Get JSON/Create JSON steps on a locally uploaded file in script works.
Response Body >
TEXT[{\n \"first_name\": \"John\",\n \"last_name\": \"Doe\"\n}]
Debugging errors as "...net.minidev.json.JSONArray cannot be cast to java.lang.String...". Attached complete message along with debug step. Appreciate any help to get past this.
Solved! Go to Solution.
04-06-2020 12:41 PM
As I pointed out in a previous post, UCCX doesn't use the same parser as jsonpath.com.
So, be sure to test your json path expressions in the correct parser, just so you don't end up driving yourself mad wondering why it works in one, but not the other.
If you are simply trying to get the first name, then all you need is this:
$.first_name
04-07-2020 07:31 AM
04-06-2020 12:26 PM
Check the named value pair in the previous step. What is the schema difference? and the subsequent Get JSON Document data is updated for 'first_name" ...? (dot dot at the beginning?) I see one is team.teamname | employees.firstname - maybe? I am learning this too... so please post back if you figure it out.
-Sean
04-06-2020 12:41 PM
As I pointed out in a previous post, UCCX doesn't use the same parser as jsonpath.com.
So, be sure to test your json path expressions in the correct parser, just so you don't end up driving yourself mad wondering why it works in one, but not the other.
If you are simply trying to get the first name, then all you need is this:
$.first_name
04-06-2020 08:03 PM
Hi Anthony,
That was the thing, Jayway JSON parser! Thank you very much for pointing it out. As always, I appreciate your help.
Not sure how I missed your previous post though I was digging for sometime, I must be searching just by the error message.
If I can ask one more thing, I was trying to do same queries to CCX API, I see it returns response in XML format like the one copied below. Is there a way to make CCX return JSON objects or the script convert XML to JSON? Or the only way to go will be with XML and XPath?
TEXT[{\"@type\":\"teamXMLList\",\"team\":[{\"self\":\"https://uccx12pub.lab.com/adminapi/team/1\",\"teamId\":1,\"teamname\":\"Default\"}]}]
04-07-2020 07:31 AM
Try sending this header in your request:
Accept: application/json
;)
04-07-2020 08:55 AM
03-22-2023 04:14 AM
I have response of string type which look like this, i got it from 'Make rest call'
U "{\"count\":1,\"next\":null,\"previous\":null,\"results\":[{\"id\":1,\"url\":\"http://xx.xx.xx.xx:xxxx/api/1/\",\"display\":\"it\",\"name\":\"it\",\"slug\":\"it\",\"account\":\"\",\"description\":\"\",\"comments\":\"\",\"asns\":[],\"tags\":[],\"custom_fields\":{},\"created\":\"2023-03-\",\"last_updated\":\"2023-03-20T12: \",\"circuit_count\":1}]}"
it contains 'U' at start and seems not valid json(uccx is converting it to such string, checked with other tools like postman other service provides response with valid json),
My requirement is to get the 'name' parameter from it which is inside the 'results' array.
I need to set the name parameter value in different String type variable. lets assume variable name as 'newName'.
Saw few post , suggesting to perform 'Create Json Document' on response string , not able to understand this step, can you give your input.
Thanks in advance.
03-22-2023 04:26 AM - edited 06-08-2023 02:14 AM
I posted a screenshot of the create JSON document step based on the result from the make REST call step that is stored in a string variable.
Did that not work for you?
03-22-2023 04:48 AM
thanks for directing me to correct post . it really helped.
05-30-2023 11:14 PM
@Roger Kallberg I need your help here,
I need to make rest call from uccx script in , that call is for Oauth .
I need to make a post call , in that call need to pass body as 'x-www-form-urlencoded' in headers and in body the credentials details
i did the same in uccx script but it is not working
First I created the string and all parameters and added that parameter in body .
Attached the scrrenshot for reference , take a look and help me out here.
Thanks in advance.
05-30-2023 11:41 PM
Sorry, but I don't have the faintest on how to do that. Have you looked over at DevNet to see if you find anything related to this?
06-02-2023 09:27 PM
I can see your screenshot getting the null value that is why getting this error.
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