Using the TVDB API with Delphi

A place for developers to advertise their enabled app and get help from other developers with the API.
Posts: 1
Joined: Mon Mar 04, 2019 2:43 am

Using the TVDB API with Delphi

Postby Prometheus » Mon Mar 04, 2019 3:15 am

I have my API key, and my user key. When I test it in the "Authentication : Obtaining and refreshing your JWT token" section of the api documentation (, then I do get a token in the response body.

However, when I attempt to post exactly the same the same JSON data authentication string:

Code: Select all

   "apikey": "XXXXXXXXXXXXXXXX",
   "userkey": ""

containing my user key and api key from a prototype delphi application (using the "TNetHTTPClient" component), it perpetually returns "{"Error":"Not authorized"}"

Code: Select all

procedure TestResponse;
  APrimaryJsonObj : TJsonObject;
  LHTTP: TNetHTTPClient;
  JSONData: TStringList;
  JSONData := TStringList.Create;
  APrimaryJsonObj := TJsonObject.Create();
  LHTTP := TNetHTTPClient.Create(nil);
    APrimaryJsonObj.AddPair(TJSONPair.Create('apikey', 'XXXXXXXXXXXXXXXX'));
    APrimaryJsonObj.AddPair(TJSONPair.Create('username', 'YYYYYYYYYYYYYYYYYY'));
    APrimaryJsonObj.AddPair(TJSONPair.Create('userkey', ''));

    JSONData.Text := APrimaryJsonObj.ToString;

    LHTTP.ContentType := 'application/json';
    LHTTP.Accept := 'application/json';

    Memo1.Lines.Text := JSONData.Text;
    Memo2.Lines.Text := LHTTP.Post('', JSONData).ContentAsString;

If I want to retrieve the information of Season 1 for Stargate SG-1 on TheMovieDB, I simply have to "download" ... APIKEYXXXX for processing using the following code:

I do not need to provide any kind of login or authorization. Just this:

Code: Select all

AUrl := MovieDB_SeasonDetails_URL(FMovieDb_SeriesID, ASearchSeason);
ProgressPrimary('Downloading Season Metadata');
if DownloadFile(AUrl, AMemoryStream, Self) then

Is there NO way at all for me to use the new TVDB JSON API in a similar manner? Or perhaps someones here can show me how to properly use the Delphi "TNetHTTPClient" component for processing all the available options of the JSON API?