Recent

Author Topic: 400 - Bad Request with Indy IdHTTP  (Read 341 times)

DanishMale

  • Jr. Member
  • **
  • Posts: 60
400 - Bad Request with Indy IdHTTP
« on: December 10, 2019, 03:37:56 am »
Hi guys!

I am creating a program to grab some information from remote sites to generate EPG data for my satellite receiver (I know that epg functions are build in)

Now when I try this URL (https://www.viasat.dk/tv-guide#!/channel?selected=YYYYMMDD) I get at Bad request 400, however, works perfectly in my web browser and the code I am using is this:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.GetWEBContent;
  2. begin
  3.   try
  4.     try
  5.       HTTPinfo := TIdHTTP.Create(nil);
  6.       IOcontroller := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
  7.       IOcontroller.SSLOptions.SSLVersions := [sslvTLSv1,sslvTLSv1_1,sslvTLSv1_2,sslvSSLv2,sslvSSLv23,sslvSSLv3];
  8.  
  9.       HTTPinfo.Request.UserAgent := 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362';
  10.       HTTPinfo.Request.Method := 'GET';
  11.       HTTPinfo.Request.Accept := '*/*';
  12.       HTTPinfo.Request.ContentType := '*/*';
  13.       HTTPinfo.Request.AcceptCharset := 'UTF-8';
  14.       HTTPinfo.Request.AcceptEncoding := 'UTF-8';
  15.       HTTPinfo.Request.Charset := 'UTF-8';
  16.       HTTPinfo.ProtocolVersion := pv1_1;
  17.       HTTPinfo.HTTPOptions := [hoForceEncodeParams,hoWaitForUnexpectedData,hoWantProtocolErrorContent];
  18.       HTTPinfo.IOHandler := IOcontroller;
  19.       http_result := HTTPinfo.Get(http_url, IndyTextEncoding_UTF8);
  20.  
  21.     except
  22.       on E: EIdHTTPProtocolException do
  23.       begin
  24.         http_result := 'HTTP: '+#13#10+'Errorcode: '+IntToStr(E.ErrorCode)+#13#10+'Errormessage: '+E.ErrorMessage;
  25.       end;
  26.       on E: Exception do
  27.       begin
  28.         http_result := 'General:'+#13#10+'Errormessage: '+E.Message;
  29.       end;
  30.     end;
  31.  
  32.   finally
  33.     HTTPinfo.Free;
  34.     IOcontroller.Free;
  35.   end;
  36. end;
  37.  

I have tried with Synapse EncodeURL and without same result,

Any one any ideas ?  :)
Lazarus 2.0.8 x64 | FPC 3.0.4 | Windows 10 x64 | Windows Server 2019 x64 | OpenVix 5.4 (Linux) | MySQL Community Server 8.0 x64 | MariaDB 10.5.8 x64 | SQLite 3.16.2 x64 | PostgresSQL 13.1 x64

 

TinyPortal © 2005-2018