0

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

Bosshoss
  • 783
  • 6
  • 24
  • 1
    Did you read [Jira's REST API](https://developer.atlassian.com/server/jira/platform/rest-apis/) documentation? – Remy Lebeau Jan 20 '19 at 18:21
  • Yes, and I didn't see anything about my problem :( – Bosshoss Jan 21 '19 at 15:56
  • 1
    really? Because I see nothing in your code that is following the API. Especially in regards to authentication, etc. That is why I mention the documentation. 400 is BAD REQUEST, which means you are sending something (or lack of something) that the API does not like. – Remy Lebeau Jan 21 '19 at 17:11

0 Answers0