Reading JSON
Posted: Fri Jul 31, 2020 3:41 pm
Hi
I'm trying to read a response back from a web service using
Define_Com Class(#PRIM_JSON.Document) Name(#lDocument)
#UniCodeString := #Request.Response.AsString.Trim
#lDocument.LoadFromString( #UniCodeString )
#msgdta := #lDocument.RootNode<'MESSAGE'>.AsString
Which is great if I get valid json. However, in some circumstances the service returns a valid response (200) but the content is a HTML error page. When this hits the LoadFromString the application ends immediately with no error messages. There seems to be no error handling available in #PRIM_JSON.Document and the response is not null.
Does any one know how I can handle this properly.
(I'm using #PRIM stuff rather than the more widely documented #XPRIM because its much faster. In this case I could probably go with #XPRIM but I'd like to stick with this.)
I'm trying to read a response back from a web service using
Define_Com Class(#PRIM_JSON.Document) Name(#lDocument)
#UniCodeString := #Request.Response.AsString.Trim
#lDocument.LoadFromString( #UniCodeString )
#msgdta := #lDocument.RootNode<'MESSAGE'>.AsString
Which is great if I get valid json. However, in some circumstances the service returns a valid response (200) but the content is a HTML error page. When this hits the LoadFromString the application ends immediately with no error messages. There seems to be no error handling available in #PRIM_JSON.Document and the response is not null.
Does any one know how I can handle this properly.
(I'm using #PRIM stuff rather than the more widely documented #XPRIM because its much faster. In this case I could probably go with #XPRIM but I'd like to stick with this.)