[SOLVED] Problems accessing information in JSON format from a URL lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Ever · 2025-04-27 02:57 Greetings I need help resolving the following situation. I need to access a web page with the following address "https://bcv.ingeint.com/api/bcv/rate" This page displays a JSON file with two fields: rate and date. Attached image with the search result I have tried several codes to access this data, but none of them work. In all cases, the name of a JSON file must be explicitly indicated along with the URL, something like "https://bcv.ingeint.com/api/bcv/rate/factor.json" But this is not the case. This page is used to calculate the exchange rate of the dollar against my country's currency. It is updated daily. I want to check this value every day to update it in a database field to execute financial transactions. I appreciate any support you can provide. ---------------------------------------------------------------------- Remy Lebeau · 2025-04-27 03:44 Quote from: Ever on April 27, 2025, 04:57:00 amI have tried several codes to access this data, but none of them work. What EXACTLY have you tried? Please show the actual code. If multiple codes are not working, then either there is a common element that is failing for all of them, or you are likely just using them wrong. Quote from: Ever on April 27, 2025, 04:57:00 amIn all cases, the name of a JSON file must be explicitly indicated along with the URL, something like "https://bcv.ingeint.com/api/bcv/rate/factor.json" If you don't have to specify a filename in a browser, then you don't have to specify it in code, either. No HTTP client should require this. ---------------------------------------------------------------------- paweld · 2025-04-27 04:54 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  fphttpclient, opensslsockets, fpjson, jsonparser; procedure TForm1.Button1Click(Sender: TObject);var  hc: TFPHttpClient;  url: String = 'https://bcv.ingeint.com/api/bcv/rate';  json: String = '';  jd: TJsonData;  jo: TJsonObject;begin  hc := TFPHttpClient.Create(nil);  try    json := hc.Get(url);  except    ShowMessage(Format('Error: [%d] - %s', [hc.ResponseStatusCode, hc.ResponseStatusText]));  end;  if json <> '' then  begin    jd := GetJson(json);    if jd <> nil then    begin      jo := TJsonObject(jd);      if (jo.Find('rate') <> nil) and (jo.Find('date') <> nil) then        ShowMessage(Format('Rate: %g from: %s', [jo.Find('rate').AsFloat, jo.Find('date').AsString]))      else      ShowMessage('Incorect json:'#13#10 + json);      jd.Free;    end;  end;  hc.Free;end; ---------------------------------------------------------------------- Ever · 2025-04-27 11:41 Thanks paweld, it worked perfectly for me.