11-13-2018, 10:35 AM
I am trying to post a JSON to web rest service but always with message HTTP1.1/BAD request.
The page in question is test page: https://dev.slimpay.com/hapi/browser#create-payins and the json is
The first two steps on the test page OK with IDHTTP and SSL but this test step i am aunable to proceed, my code is the following:
htpBrwsr is an TIDHttp related to a TIdSSLIOHandlerSocketOpenSSL, a similar TIDHttp functions well in the first two steps sited on the test page and I obtain the token with no problems.
any help will be aprecieted..
The page in question is test page: https://dev.slimpay.com/hapi/browser#create-payins and the json is
Code:
POST Follow(https://api.slimpay.net/alps#create-payins) HTTP/1.1
Accept: application/hal+json; profile="https://api.slimpay.net/alps/v1"
Authorization: Bearer token
Content-Type: application/json
{
"creditor": {
"reference": "democreditor"
},
"subscriber": {
"reference": "subscriber5bea84af2e9e3"
}
}
The first two steps on the test page OK with IDHTTP and SSL but this test step i am aunable to proceed, my code is the following:
Code:
htpBrwsr.Request.Accept := 'application/hal+json; profile="https://api.slimpay.net/alps/v1"';
htpBrwsr.Request.CustomHeaders.Add('Authorization: Bearer ' + sToken); // token got correctly from previous step
htpBrwsr.Request.ContentType := 'application/json';
// htpBrwsr.Request.CharSet := 'UTF-8';
ms := TMemoryStream.Create;
ss := TStringStream.Create('{"creditor": {"reference": "democreditor"},"subscriber": {"reference": "subscriber5bea84af2e9e3"}}');
ss.Position := 0;
htpBrwsr.Post('https://api.preprod.slimpay.com/payments/in', ss, ms); // error HTTP1.1/400T
htpBrwsr is an TIDHttp related to a TIdSSLIOHandlerSocketOpenSSL, a similar TIDHttp functions well in the first two steps sited on the test page and I obtain the token with no problems.
any help will be aprecieted..