Error encountered while calling an API
Hello, I have a problem with a call and I would need some help.
When I call an API with the SendFormDataArray method of the EnsLib.HTTP.OutboundAdapter adapter, I pass it a %Net.HttpRequest object and I receive the following error:
ERROR #5002: ObjectScript error: <SUBSCRIPT>MatchSuffix+1^%Net.HttpRequest.1 ^%qPublicSuffix("")
I have correctly entered the url in my business operation and I pass it in the last parameter of the SendFormDataArray method. Do you have any idea, please?
Method XRPUAuthentification(pInput As ANCV.msg.BO.XRPUAuthentificationDmde, Output pOutput As ANCV.msg.BO.XRPUAuthentificationRpse) As %String
{
Set pOutput = ##class(ANCV.msg.BO.XRPUAuthentificationRpse).%New()
Try{
Set httpRequest = ##class(%Net.HttpRequest).%New()
Set utilisateur = ##class(ANCV.WebObjet.wsXRPUUtilisateur).%New()
Set utilisateur.login = ..RecupererLogin()
Set utilisateur.password = ..RecupererMdp()
Do httpRequest.SetHeader("Content-Type", "application/json")
//Transformation du message d'entrée en JSON
Set tSC = ..ObjectToJSONStream(utilisateur, .entityBody)
$$$ThrowDecomposeIfError(tSC, "Impossible de transformer le message", $$$ErreurRecuperationToken)
Set httpRequest.EntityBody = entityBody
//Appel à l'api security/authentication
set tSC = ..Adapter.SendFormDataArray(.response, "POST",httpRequest,,,..Adapter.URL_"/security/authentication")
$$$ThrowDecomposeIfError(tSC, "Impossible d'appeler l'api", $$$ErreurRecuperationToken)
//Transformation du JSON de retour en message
set tSC = ..JSONStreamToObject(response.Data, .pOutput, "ANCV.msg.BO.XRPUAuthentificationRpse", 1)
$$$ThrowDecomposeIfError(tSC, "Impossible de récupérer le token", $$$ErreurRecuperationToken)
set pOutput.codeRetour = "OK"
} Catch Exception {
Set pOutput.codeRetour = "KO"
Set pOutput.libErreur = Exception.DisplayString()
Set pOutput.codeErreur = Exception.Code
}
Quit $$$OK
}
Method RecupererLogin() As %String
{
Quit ##class(Ens.Config.Credentials).GetValue(..Adapter.Credentials, "Username")
}
Method RecupererMdp() As %String
{
Quit ##class(Ens.Config.Credentials).GetValue(..Adapter.Credentials, "Password")
}
ObjectScriptObjectScript
Product version: IRIS 2024.1
Can you check if in the cookie sent back the domain is empty.
Something like this :
my-token=eyJhbGciO...C4grnBXBPeVc5A;Version=1;Comment=;Domain=;Path=/;HttpOnly
If so, it's a know bug, that is solved in 2024.2, i can help you with an ad hoc patch, otherwise, it some thing else.