HTTP Error 406 using Rest Delphi components with XML return

1

I'm trying to query an NFS-e with the REST components in delphi XE7, in the queries of type Json I got normally, but when the return is of type XML it gives the error 406, I already tried to send the Accept and Content-Type in the header but also did not solve, someone has already gone through this situation? do I need to do some differentiated treatment when return is XML?

Follow the code:

  RESTRequest.ResetToDefaults;
  RESTClient.ResetToDefaults;
  RESTResponse.ResetToDefaults;

  RESTClient.BaseURL := 'https://nfps-e-hml.pmf.sc.gov.br/api/v1/consultas/notas/xml/126564/4554566';

  RESTClient.Authenticator := nil;

  RESTRequest.Method := TRESTRequestMethod.rmGET;

  RESTRequest.Execute;

  Memo1.Clear;
  Memo1.Lines.Text := RESTResponse.Content;

Error:

    
asked by anonymous 19.01.2018 / 19:39

1 answer

1

Before Execute set an appropriate Accept to the file you are trying to access:

RESTRequest.Accept := 'text/xml';
RESTRequest.Execute;

Perform the tests and report the result.

    
22.01.2018 / 11:56