Hi there,
I´m trying to do a HttpClient.Send() in a BC20 Sandbox scenario with the following code ;
procedure SendXml(pXmlDocument: XmlDocument)
var
Client: HttpClient;
Headers: HttpHeaders;
RequestMessage: HttpRequestMessage;
ResponseMessage: HttpResponseMessage;
Content: HttpContent;
Cert: text;
Password: Text;
myTxtXml: Text;
CertificateEnabled: Boolean;
lTxtWebServiceUrl: Text;
lTxtStatusDescp: Text[250];
lTxtResponse: Text;
begin
GetAndCheckSetup();
CertificateEnabled := GetCertificateInfo(Cert, Password);
if not CertificateEnabled then begin
ProcessResponseCommunicationError(NoCertificateErr, '');
exit;
end;
lTxtWebServiceUrl := 'someValidUrlEndPoint';
StoreRequestXml(pXmlDocument);
Clear(RequestMessage);
Clear(Content);
Clear(Headers);
Clear(Client);
RequestMessage.SetRequestUri(lTxtWebServiceUrl);
RequestMessage.Method := 'POST';
pXmlDocument.WriteTo(myTxtXml);
Content.WriteFrom(myTxtXml);
Content.GetHeaders(Headers);
Headers.Remove('Content-Type');
Headers.Add('Content-Type', 'application/xml');
RequestMessage.Content := Content;
Client.AddCertificate(Cert);//Client.AddCertificate(Cert,Password);
if not Client.Send(RequestMessage, ResponseMessage) then begin
ProcessResponseCommunicationError(NoResponseErr, '');
exit;
end else begin
Headers := ResponseMessage.Headers;
Content := ResponseMessage.Content;
lTxtStatusDescp := Format(ResponseMessage.HttpStatusCode());
ResponseMessage.Content.ReadAs(lTxtResponse);
if not ResponseMessage.IsSuccessStatusCode() then begin
ProcessResponseCommunicationError(
StrSubstNo(CommunicationErr, lTxtStatusDescp),
lTxtResponse);
exit;
end;
ProcessResponse(lTxtResponse);
end;
end;
The response returns a "Not valid identification or digital certificate not valid.", but gives me a 200 status. The certificate its added in Base64, working for another uses, and check with a decode tool with valid information ;

Can someone help me with the code review or if there is any problem in associating the certificate to the web service call?
Thank you,