0
I’m trying to access Delphi’s idHTTP on a json server without success. I have tried all alternatives and always have the same error: "HTTP/1.1 401 Unauthorized".
Json format submitted for testing:
{"http":{"method":"POST","header":"access_token:55b3ce85b47629ee778c0f0c9be450f1b1bc84cc377975f2d3d0d3808a4636", "content":"name=Teste&[email protected]&phone=1147001211&mobilePhone=11992329909&address=Rua+Jose+Ricardo &addressNumber=55&Province=Bairro¬ificationdisabled=True&city=Sao+Paulo&state=Sp&country=Brazil&postalcode=05567210 &cpfCnpj=11111111111&personType=FISICA"}}
Url for testing:
http://homolog.asaas.com/api/v2/customers
Procedure used for testing:
procedure TForm4.Button2Click(Sender: TObject);
var
sResponse: string;
EnvStr : TStringList;
begin
// 2
EnvStr := TStringList.Create;
EnvStr.AddStrings(Memo.Lines);
try
idHTTP.Request.ContentType := 'application/json';
idHTTP.Request.Method:='POST';
idHTTP.Request.AcceptCharSet := 'utf-8';
try
sResponse := idHTTP.Post(EditURL.Text,EnvStr);
except
on E: Exception do
ShowMessage('Error on request: '#13#10 + e.Message);
end;
finally
MemoRet.Lines.Clear;
MemoRet.Lines.add(sResponse);
end;
end;
The same format sent in PHP works perfectly, but with idHTTP returns the error: "HTTP/1.1 401 Unauthorized".
Does anyone already do this procedure in Delphi with asaas.com? Thank you in advance!