Ver Mensaje Individual
  #14  
Antiguo 03-01-2024
Badillo Badillo is offline
Miembro
 
Registrado: jun 2021
Posts: 33
Reputación: 0
Badillo Va por buen camino
Probé de esta otra forma y mismo error.

Saludos.

Probé de está otra forma, incluyendo lo que me comenta pablog2k y como resultado obtengo el mismo error:

Código Delphi [-]
function TValidateNPIForAPI.ValidateNPIForAPI(aNumber, aNpiType,
  aTaxonomy: string): boolean;
var
  AHTTP: TIdHTTP;
  SSL: TIdSSLIOHandlerSocketOpenSSL;
  xResponse: TStringStream;
  xUrl, xParams: String;
  xJsonObj: TlkJSONbase;
  xCount: Integer;
begin
  Result := False;
  xUrl :=  'https://npiregistry.cms.hhs.gov/api/?version=2.1';
  xResponse := TStringStream.Create('');
  xJsonObj :=  TlkJSONbase.Create;

  if aNumber <> '' then
    xParams := xParams + '&number='+HttpEncode(aNumber);

  if aNpiType <> '' then
    xParams := xParams + '&enumeration_type='+HttpEncode(aNpiType);

  if aTaxonomy <> '' then
    xParams := xParams + '&taxonomy_description='+HttpEncode(aTaxonomy);

  try
    AHTTP:= TIdHTTP.Create(nil);
    SSL:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);

    AHTTP.IOHandler:= SSL;
    AHTTP.AllowCookies:= True;
    AHTTP.HTTPOptions:= [hoForceEncodeParams];

    AHTTP.Request.BasicAuthentication:= True;

    AHTTP.Request.Accept:= 'application/json';
    AHTTP.Request.AcceptCharSet := 'utf-8';
    AHTTP.Request.ContentType:= 'application/json';
    AHTTP.Request.UserAgent:= 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0';
    AHTTP.Request.CharSet:= 'utf-8';

    SSL.SSLOptions.Method:= sslvSSLv23;
    SSL.SSLOptions.Mode:= sslmUnassigned;
    SSL.SSLOptions.VerifyMode:= [];
    SSL.SSLOptions.VerifyDepth:= 0;
    SSL.SSLOptions.SSLVersions := [sslvTLSv1_2, sslvTLSv1_1, sslvSSLv23, sslvTLSv1];

    xParams := AHTTP.Get(xUrl + xParams);
    TlkJSONbase(xJsonObj) := TlkJSON.ParseText(xResponse.DataString);
    xCount := StrToInt(xJsonObj.Field['result_count'].Value);
    Result := (xCount > 0);
  finally
    xResponse.Free;
    xJsonObj.Free;
    SSL.Free;
    AHTTP.Free;
    Result := False;
  end;
end;

Gracias.
Responder Con Cita