I try to get content from a website (Jira rest api in https). In my enterprise there is sso to connect to this website.
When I use idHTTP to get content I got a HTTP 1.1 400.
There is a existing software who do that write in Java. Firstly we need to open the website with Chrome because it use a .cookies.db file.
My first code :
procedure TFMain.Button1Click(Sender: TObject);
var
lHTTP: TIdHTTP;
res: string;
begin
lHTTP := TIdHTTP.Create;
try
res := lHTTP.Get(edApi.Text);
Memo1.Lines.Add(res);
finally
lHTTP.Free;
end;
end;
My second code :
procedure TFMain.Button3Click(Sender: TObject);
var
HTTP : TIDHTTP;
Cookie : TidCookieManager;
res: string;
begin
try
HTTP := TIDHTTP.Create(nil);
Cookie := TidCookieManager.Create(nil);
HTTP.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1';
HTTP.Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
HTTP.Request.AcceptLanguage := 'en-us;q=0.7,en;q=0.3';
HTTP.Request.AcceptCharSet := 'windows-1251,utf-8;q=0.7,*;q=0.7';
HTTP.Request.Pragma := 'no-cache';
HTTP.Request.CacheControl := 'no-cache';
HTTP.Request.RawHeaders.Add('X-Requested-With: XMLHttpRequest');
HTTP.AllowCookies := True;
HTTP.HandleRedirects := True;
HTTP.ProtocolVersion := pv1_1;
HTTP.Request.Connection := 'Keep-Alive';
HTTP.CookieManager := Cookie;
res := http.Get(edApi.Text);
Memo1.Lines.Clear;
Memo1.Lines.Add(res);
finally
FreeAndNil(Cookie);
FreeAndNil(HTTP);
end;
end;
I didn't really know what to do now.. thanks