Trying to do a get() with Digest to a partner's web service with Delphi XE.
I have included IdAuthenticationDigest
to the uses clause which should automatically work from what I've read - but I must be missing something because I'm getting a 401 Unauthorized.
Code:
begin
// Init request:
IdHttp := TIdHttp.Create(nil);
try
idHttp.Request.ContentType := self.inputType; // 'application/xml'
idHttp.Request.Accept := self.outputType; //'application/json';
// Set request method:
idHttp.Request.Method := Method; // 'Get'
// Set username and password:
idHttp.Request.BasicAuthentication := False;
// IdHttp.Request.Username/Password also fails
IdHttp.Request.Authentication.Username := 'xx';
IdHttp.Request.Authentication.password := 'xx';
IdHttp.Request.ContentLength := Length(Body);
// Send request:
if Method = 'GET' then
Result := idHttp.Get(self.ServiceHost + URI)
else
if Method = 'POST' then
Result := idHttp.Post(self.ServiceHost + URI, SendStream);
finally
idHttp.Free;
end;
end;