By Kristinn Sigurthorsson on Wednesday, 20 November 2024
Posted in Support
Likes 0
Views 24
Votes 0
I am trying to post to a web service but I am getting an error from the server.
We have narrowed the problem to the data not being UTF-8 (if we post it using Postman it goes through)

The Post function generated by esegece

var
oRequest: TsgcOpenAPIRequest;
begin
oRequest := TsgcOpenAPIRequest.Create;
Try
oRequest.Method := oapiHttpPOST;
oRequest.Endpoint := '/payVehicleDebt';
oRequest.Security := oapiSecurityBasic;
oRequest.Body := aBody;

oRequest.ContentType := 'application/json; charset=utf-8'; //KS - changes nothing
EncodeBodyAsUTF8 := true; //KS
result := DoHTTP_REQUEST(oRequest, aResponse);
Finally
sgcFree(oRequest);
end;


the body contains one UTF-8 character

{
"officeID": "1000",
"nationalID": "0000000000",
"carNumber": "JM123",
"payments": [
{
"chargeType": "BÞ",
"payAmount": 301736
}
],
"TotalPayAmount": 301736,
"reference": "1010722"
}

Anyone had the same problem and found a solution?
View Full Post