2

I slowly working my way through the HMRC tutorials and I'm now stuck on the second example:

/hello/application

https://developer.service.hmrc.gov.uk/api-documentation/docs/tutorials

I have registered with the HMRC and been issued a "Server Token". This is used on the /hello/application but I have tried 13 different code variants but all I get is:

{"code":"MISSING_CREDENTIALS","message":"Authentication information is not provided"}

Here's 1 instance I've tried:

procedure TfrmMain.btnHello_Application_RESTClient_TestClick(Sender: TObject);
var
  jValue: TJSONValue;
begin
  MemoContent.Lines.Clear;
  RESTClient1.BaseURL := 'https://test-api.service.hmrc.gov.uk/hello/application';
  RESTRequest1.Params.Clear;
  RESTRequest1.Params.AddItem('Accept', 'application/vnd.hmrc.1.0+json');
  RESTRequest1.Params.AddItem('Authorization', 'Bearer ' +   eHello_Application_Server_Token.Text, pkHTTPHEADER, []);           
  RESTRequest1.Execute;

  jValue := RESTResponse1.JSONValue;
  MemoContent.Text := jValue.ToString;
end;

Any idea how to use the REST Client with a server token as an Authorization header with the type Bearer in a Delphi?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Yuppski
  • 137
  • 2
  • 10
  • 8
    I have found the solution. I needed to add a TOAuth2Authenticator component setting the properties TokenType = ttBEARER and the Access Token = [Your Server Token] and not adding any RESTRequest1.Params.AddItem at runtime. – Yuppski Oct 16 '18 at 09:05

0 Answers0