-
mattaranettaDomanda del 7 febbraio 2024 alle ore 12:57
Buongiorno,
ho la necessità di interagire tramite API da un mio applicativo.
Ho usato la chiamata GET https://eu-api.jotform.com/user?apikey=xxxx
Da browser funziona ma non dal mio applicativo che peraltro uso frequentemente per connettermi ad altre piattaforme.
Mi da' errore 403 Forbidden
C'è qualche Header particolare che devo settare nell'oggetto idHTTP ?
E' possibile vedere un log della chiamate per vedere cos'è arrivato al server ?
Grazie
-
Bojan Support Team LeadRisposta del 7 febbraio 2024 alle ore 16:23
Hi mattaranetta,
Thanks for reaching out to Jotform Support. Unfortunately, our Italian Support agents are busy helping other Jotform users at the moment. I'll try to help you in English using Google Translate, but you can reply in whichever language you feel comfortable using. Or, if you'd rather have support in Italian, let us know and we can have them do that. But, keep in mind that you'd have to wait until they're available again.
Now, let me help you with your question. Please ensure you are using the GET method to retrieve the data. Also, please ensure that you have all permissions on your device to run the call. If everything is fine, please share a full screenshot of the message you receive so we could investigate the issue further.
As soon as we hear back from you, we can move forward with a solution.
-
mattaranettaRisposta del 8 febbraio 2024 alle ore 09:50
Hi Bojan,
I used GET https://eu-api.jotform.com/user?apikey=xxx to get the user information.
I tried it on httpie and it works fine with the correct apikey.
I have the problem when I implement the call on my Delphi program using idHTTP component.
The answer is generic "403 forbidden".
idHTTP works fine with other API platform.
I don't understand which parameter or header I have to set to get the correct result.
Is it possible to have a log of my call to see what arrives at the server?
Thank you
-
Sweta Jotform SupportRisposta del 8 febbraio 2024 alle ore 12:25
Hi ,
Can you try out the following Delphi code to fetch the user details?
uses
IdHTTP, SysUtils;
function FetchJotFormUserData(apiKey: string): string;
var
IdHTTP: TIdHTTP;
begin
IdHTTP := TIdHTTP.Create(nil);
try
// Set the API key in the Authorization header
IdHTTP.Request.CustomHeaders.AddValue('Authorization', 'Bearer ' + apiKey);
// Perform GET request to fetch user data
Result := IdHTTP.Get('https://eu-api.jotform.com/user');
finally
IdHTTP.Free;
end;
end;
procedure Main;
var
apiKey: string;
userData: string;
begin
// Replace 'YOUR_API_KEY' with your actual API key
apiKey := 'YOUR_API_KEY';
// Fetch user data from the Jotform API
userData := FetchJotFormUserData(apiKey);
// Display fetched data
Writeln(userData);
end;
begin
Main;
end.
Can you share the logs that you are getting while running the code?
Give it a try and let us know if you need any help.
-
mattaranettaRisposta del 9 febbraio 2024 alle ore 03:55
Hi Sweta,
thank you for your answer.
I tried adding the header Authorization/Bearer but it didn't work.
Then I tried to whiten all the headers one by one and it finally worked by whitening the header UserAgent.
The contents of UserAgent were "Mozilla/3.0 Compatible; (Indy Library)"
Whitening UseAgent works (do not ask me why).
Thank you.
idHTTP := TidHTTP.Create(nil);
LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
try
LHandler.SSLOptions.Method := sslvTLSv1_2;
LHandler.SSLOptions.SSLVersions := [sslvTLSv1_2];
idHTTP.IOHandler := LHandler;
idHTTP.Request.UserAgent := '';
URL := 'https://eu-api.jotform.com/user?apikey=' + apiKey;
Result := IdHTTP.Get(URL);