HTTP Response parsing error
Hello
I'm in the process of creating a TestClass which simulate a HTTP POST call to REST-based web
services and while I am having success, I'm struggling on how to parse out the results to a JSON
format
Here is down the code part which concerns parsing the HttpResponse.Data variable into JSON :
s httprequest=##class(%Net.HttpRequest).%New()
s httprequest.Server="http://127.0.0.1"
s httprequest.Port="57772"
s httprequest.Https = 0
s httprequest.ContentType="application/json"
s httprequest.Authorization = "Basic X1N5c3RlbTpTWVM="
d httprequest.EntityBody.Write(json)
s sc = httprequest.Post("http://127.0.0.1:57772/api/v0/bwxpert/visiocheck/account")
Do $$$AssertStatusOK(sc,"HTTP POST OK")
Set Result= httprequest.HttpResponse.Data
Set DynamicObject = {}.%FromJSON(Request.HttpResponse.Data)
Do $$$AssertEquals(Result.syncType,"ADMIN_SYNC","sync OK")
write DynamicObject.%ToJSON(),!
When run the tests on Terminal i get this httpresponse content displayed :
{"errors":[{"code":5035,"domain":"%ObjectErrors","error":"ERREUR #5035: Exception générale Nom 'Parsing error' Code '3' Données ''","id":"GeneralException","params":["Parsing error",3,""]}],"summary":"ERREUR #5035: Exception générale Nom 'Parsing error' Code '3' Données ''"}
Any idea about this issue ?
Thank you in advance