I am trying to use Query JSON to pull GSA current rates for a travel reimbursement form and it's giving me fits! Since this is a GSA rates query, I'm hoping it's a pretty common usage and some of you are also using it for travel reimbursement forms/workflows of your own.
I'm using the Query JSON action in NWC. To test it, I followed the Nintex help to put my JSON into a string convertor, then put it into the JSON Path tester. I wrote a workflow that calls the web service, then emails me the text of the response to get the full response text for testing.
Yesterday when I did this, the string converter worked, today I can't get it to, I get no error, nothing, just an empty results box. When t worked yesterday, it looked like all it did was replace " with ""
When I put the response content into the tester, I get something like this every time:
After parsing a value an unexpected character was encountered: r. Path 'JSON', line 2, position 13."
I tried using search and replace in notepad to get the backslashes added, but I get the same result.
My API calls to GSA are working, I can put the results in firefox or code beautify and see the tree view, and validators say it passes, so I know that part is good.
The one time I got it to work, I used this (leaving off my API key):
https://api.gsa.gov/travel/perdiem/v2/rates/zip/64110/year/2022?api_key=
Result was this:
{"request":null,"errors":null,"rates":a{"oconusInfo":null,"rate":r{"months":{"month":o{"value":123,"number":1,"short":"Jan","long":"January"},{"value":123,"number":2,"short":"Feb","long":"February"},{"value":123,"number":3,"short":"Mar","long":"March"},{"value":123,"number":4,"short":"Apr","long":"April"},{"value":123,"number":5,"short":"May","long":"May"},{"value":123,"number":6,"short":"Jun","long":"June"},{"value":123,"number":7,"short":"Jul","long":"July"},{"value":123,"number":8,"short":"Aug","long":"August"},{"value":123,"number":9,"short":"Sep","long":"September"},{"value":123,"number":10,"short":"Oct","long":"October"},{"value":123,"number":11,"short":"Nov","long":"November"},{"value":123,"number":12,"short":"Dec","long":"December"}]},"meals":64,"zip":"64110","county":"Jackson / Clay / Cass / Platte","city":"Kansas City","standardRate":"false"}],"state":"MO","year":2022,"isOconus":"false"}],"version":null}
Then, to get the rate for May, I used this expression:
$.rate$0].months.month.4].value
Result was correct:
200 OK
"FirstMatch": 123, "AllMatches": c123]}
- So what am I missing today that the blasted converter won't work?
- If the text needs to be converted to test it, do I need a regular expression to convert it in NWC between the web call and the JSON query?
- If so, WHY??? And what should the regex be?
TIA.