07-27-2020 11:52 PM
Here is the NXG block diagram that is throwing a JSON Error
And I get this error in NXG
String Constant is blank, and body contains this:
<Response><Terminal><Name>error out</Name><Value><Name>status</Name><Value>0</Value><Name>code</Name><Value>0</Value><Name>source</Name><Value></Value></Value></Terminal><Terminal><Name>string</Name><Value>{"0":"First"}</Value></Terminal></Response>
And here is the LV2017 WEB Service that is supposed to respond with a String.
The service does put the correct JSON string out
Help !!
Keith
Solved! Go to Solution.
07-30-2020 02:11 PM
@DeOdderKeith wrote:
And I get this error in NXG
Hi, DeOdderKeith!
Per the error code that I looked up via Google,
−375003 | The JSON string is invalid. JSON strings must be encoded in UTF-8 and must conform to the JSON grammar. |
Looks like the returned string doesn't confirm to JSON grammar.
@DeOdderKeith wrote:
String Constant is blank, and body contains this:
<Response><Terminal><Name>error out</Name><Value><Name>status</Name><Value>0</Value><Name>code</Name><Value>0</Value><Name>source</Name><Value></Value></Value></Terminal><Terminal><Name>string</Name><Value>{"0":"First"}</Value></Terminal></Response>
In fact, it looks a lot like XML (which I learned via a Google Search while writing this response).
In a previous thread, the solution you accepted mentions that for a LabVIEW Web Service you control, "you can change the response format to JSON".
If you follow the video instructions shown in the .gif file (called JSONOutputType.gif), it shows you how to change the output of your web service from XML to JSON.
@DeOdderKeith wrote:
And here is the LV2017 WEB Service that is supposed to respond with a String.
It looks like you tried to produce the same result without using the instructions, since your indicator, "string", has proper JSON grammar.
But, what you did just outputs the JSON string as a literal string. It will then send out that string in XML format...which is what you are receiving, but in XML format...
Conclusion:
If you want it to output in a format that is readable by "Unflatten from JSON", please follow the well documented steps to change your Web Service output to JSON.
To give you a little more help, since I think you're outputting something you don't expect, let's parse that XML for you.
If you break it down to Start tags and End tags, it becomes
<Response>
<Terminal>
<Name>
error out
</Name>
<Value>
<Name>
status
</Name>
<Value>
0
</Value>
<Name>
code
</Name>
<Value>
0
</Value>
<Name>
source
</Name>
<Value>
</Value>
</Value>
</Terminal>
<Terminal>
<Name>
string
</Name>
<Value>
{"0":"First"}
</Value>
</Terminal>
</Response>
Which, if we use our intuition, looks like this:
error out [cluster]
status [boolean]
0
code [long]
0
source [string]
"" (empty string)
string [string]
{"0":"First"}
(using a mark-up language I just made up)
or, better yet, like this:
(Using LabVIEW with NXG Style indicators. I don't have NXG, but I figure this is close enough.)
This, not coincidentally, matches the outputs of your Web Service exactly.
@DeOdderKeith wrote:
And here is the LV2017 WEB Service that is supposed to respond with a String.
Conclusion:
If you don't want to send the "error out" cluster from your Web Service, don't create an "error out" indicator.
Maybe you want to send it, but from your description and code screenshots, I don't think you do.
Please let the community know if this helped.
Regards,
joeorbob
P.S. If you haven't yet, you might look at this forum document. It uses LabVIEW instead of NXG, but seems like it has a lot of good information related to what you're doing.
07-30-2020 05:13 PM
Thanks so very much.
I guess as i get older it's getting harder to learn the first time and I have to be beat over the head.
That was it !!
KM