I am trying to access idHTTP from Delphi on a json server without success. I've tried all the alternatives and I always have the same error: "HTTP / 1.1 401 Unauthorized".
Json format submitted for testing:
{"http": {"method": "POST", "header": "access_token: 55b3ce85b47629eeee778c0f0c9be450f1b1bc84cc377975f2d3d0d3808a4636", "content": "name = TEST & email = [email protected] & phone = 1147001211 & mobilePhone = 11992329909 & address = Street + Jose + Ricardo & addressNumber = 55 & province = Neighborhood & notificationDisabled = True & city = Sao + Paulo & State = SP & country = Brazil & postalCode = 05567210 & cpfCnpj = 11111111111 & personType = PHYSICS "}}
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 it returns the error: "HTTP / 1.1 401 Unauthorized."
Does anyone already do this in Delphi with asaas.com? Thank you in advance!