0
votes

On to more curious challenges in the Delphi/Indy/TWebBrowser/Tableau saga.

I'm having a very hard time understanding why sending a GET request to the Tableau server utilizing the TIdHttp component always returns a JSON response, while the same request in a TWebBrowser control with the same auth header returns an XML response.

I slightly prefer XML - even though it is more bandwidth intensive - since we have much XML infrastructure and currently no JSON infrastructure.

When I send the request with the TIdHttp component, I'm sending it with the following params:

  http.Request.CustomHeaders.Text := GetAuthHeader(FToken);
  http.Request.ContentType := 'application/json';

I've also tried this:

  http.Request.ContentType := 'text/xml';
  http.Request.Accept := 'text/xml';

And

  http.Request.ContentType := 'application/xml';
  http.Request.Accept := application/xml';

And

  <no settings specified for accept and contenttype, just let it use the defaults>

...

  sHTML := http.Get('http://<myserver>/api/3.0/sites/' + FSiteId + '/views')

...and always receive back the response in JSON.

When I send the same request with TWebBrowser:

var
  hdr,flags,targetframe,postdata,Aurl: OleVariant;
begin
  AUrl := http://<myserver>/api/3.0/sites/' + FSiteId + '/views';
  flags := navNoHistory+navNoReadFromCache+navNoWriteToCache;
  targetframe := 1;
  postdata := 1;
  hdr := GetAuthHeader(FToken);
  Navigate2(Aurl,flags,targetframe,postdata,hdr);
end;

...the response always comes back as XML.

Does anyone understand why this would occur? I've tried logging the raw request to see how it's being set up by TWebBrowser, but can't seem to get the raw request. Perhaps I should set up a proxy server...

TIA

1

1 Answers

0
votes

Solved - had a

http.Request.ContentType := 'application/json...';

and a

http.Request.Accept := 'application/json...';

still hanging around from the form create event.