04-11-2018 07:49 PM - edited 03-14-2019 06:06 PM
Hi,
I'm new using REST/JSON in UCCX,
My question is about parsing the REST response to a local UCCX variable
This is the response for the REST POST
TEXT[{\"response\":{\"pdTotalAmount\":"13705.12"}}]
Then I'm using the GetJSON Document Data with this JSON Path "$.pdTotalAmount"
But in the Result Data get null value
Attached a screenshot for the config
I'm missing something?
Thanks
04-12-2018 09:52 AM
I highly recommend testing your JSON Paths before getting into UCCX, as UCCX is not the best at explaining to you what you did wrong.
I use this site:
So, based on the testing, it looks like your JSON Path is in fact returning no results.
If we look at the structure of your JSON object, and the Path you chose, we can see that the pdTotalAmount node is not at the root level, but rather inside the response node, as a child.
Therefore, you're new JSON Path should be:
$.response.pdTotalAmount
Bonus Tip
If you are sure that pdTotalAmount will be unique in the document structure, then you could just use the wildcard *, to search for it, in the entire document, without having to specify the entire path to it.
*.pdTotalAmount
You can read/learn more about JSON Path here:
https://www.pluralsight.com/blog/tutorials/introduction-to-jsonpath
04-12-2018 05:15 PM
Thanks a lot Anthony.
The jsonon Path that you recomend worked. It send me the value I want.
this is the $.response.pdSaldoTotal
when I try to add this value to the cisco iccx script editor I get an Document error.
Please see attached files.
I get a document exception and the value of the GetJsonDocumentData its not stored in my Variable.
the Variable that will store the value is called saldo and is type string and the JsonNotifyresponse variable is type document.
Do you know how can I store the value in a variable. ?
Best Regards and thanks for your help.
04-12-2018 05:17 PM
04-13-2018 08:28 AM
04-13-2018 09:32 AM
I just made a sample script for you, to see if this works in 11.6, and I was successful. See if you can replicate what I'm doing from the below screenshot, in your system.
04-13-2018 10:12 AM
04-13-2018 11:43 AM
Hi Anthony,
We already did some tests and we detect this difference in the http_response
Customer WebService Response:
TEXT[{\"response\":{\"pdSaldoTotal\":188904.34}}]
With your example the response is:
TEXT[{\"response\":{\"pdSaldoTotal\":\"188904.34\"}}]
In your http_response you are adding these characters \"
Attached is the error that UCCX is displaying
Thanks
04-15-2018 09:09 PM
Hi Anthony,
We just change the variable type from string to float and works. -)
In other web service, this is the response.
TEXT[{\"response\":{\"TSaldoA\":{\"TSaldoA\":[{\"TiCodProducto\":1041,\"TiCodCuenta\":6572500,\"TdSaldoD\":42.97}]}}}]
Using jsonpath.com with this output works, but in UCCX not, attach is the error that is appearing.
java.lang.Class.CastException: net.minidev.json.JSONArray cannot be cast to java.Number; nexted exception
Any idea?
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