Back

Calling api through postman is working but not through functions

  • 0
  • Self Hosted
  • Functions
eno
17 Jun, 2023, 09:34

Oh man I have been trying this trick for whole week and it didn't work LOL

TL;DR
The user is experiencing an issue where API calls work in Postman but not when made through functions. They suspect it might be a firewall issue. The solution suggested is to wrap the code in a try catch and increase the function timeout to 5 minutes to see if an error is returned. The user is also asked to check if there's a firewall enabled on the server and try testing with it disabled. Additionally, the user is asked to check the logs using `docker compose logs` and verify if the appwrite cli is being used.
safwan
17 Jun, 2023, 09:35

LMAO sadddd i'm still trying to think if I missed a step lol

safwan
17 Jun, 2023, 09:36

also just to be sure, you are using the appwrite cli right?

eno
17 Jun, 2023, 09:49

yes

eno
17 Jun, 2023, 10:10

As I said, I do all the same steps in cloud.appwrite.com and It works as it should. Only when I try in this self-hosted doesn't work

Maniac_Fighter
17 Jun, 2023, 10:54

since you are on self hosted version. What does docker compose logs say ? after executing the function

eno
17 Jun, 2023, 11:16

I just asked the guy who has access to the server to check and will get back to you as soon he msg back

Drake
17 Jun, 2023, 15:54

Can you also check if there's a firewall enabled on the server? If so, try testing with the firewall disabled

eno
17 Jun, 2023, 19:21

Executing Runtime: luna-648d7a3b4bf0c404552c [Error] Type: Exception [Error] Message: An internal curl error has occurred within the executor! Error Msg: Operation timed out [Error] File: /usr/src/code/app/executor.php [Error] Line: 544

eno
17 Jun, 2023, 19:26

They told me that there is no firewall active, and they didn’t change a lot from the standard config.

Also there is a reveres proxy in front of the server for ssl cert.

Drake
17 Jun, 2023, 19:27

Other API calls from your client app work right?

eno
17 Jun, 2023, 19:30

If I understood your question correctly, yes for example flutter developers they can access the api calls also if I use postman and make a call directly with endpoints it works but when i deploy the function and execute with php sdk or node sdk i dosent work

Drake
17 Jun, 2023, 19:31

Oh right you said postman works

Drake
17 Jun, 2023, 19:32

Can you try to wrap your code in a try catch and don't forget to call res->json() in your catch before returning.

Then, increase your function timeout to 5 minutes.

Hopefully, you'll see an error after that

eno
18 Jun, 2023, 07:06

Response: {"message":"Error!","result":[]}

eno
18 Jun, 2023, 07:10

I change the catch Class to Exception

and got this response

{"message":"Error!","result":"Failed to connect to domainoftheerver.eu port 443 after 130149 ms: Couldn't connect to server"}

Drake
18 Jun, 2023, 14:58

Awesome! So maybe it's a networking or routing or firewall issue 🧐

Drake
18 Jun, 2023, 14:59

Some ways to test and troubleshoot this are to see if a request is success from the server itself and then from the runtime container

eno
19 Jun, 2023, 06:45

Is this normal for example to work for postman calls etc but not for functions calls

safwan
19 Jun, 2023, 07:26

not sure tbh, as whenever I got curl errors on function executions, they get fixed after a few trial and errors lmao

Drake
19 Jun, 2023, 14:50

Not really. Usually, this is a firewall problem

eno
19 Jun, 2023, 15:02

I'm still having the same problem. I asked the guy and he told me firewall is disabled also he reconfigred the ssl, nowhttp redirects to https.

Also if a make a function that returns for examle string it works fine $res->json("test), but not these others

Drake
19 Jun, 2023, 15:21

so how is checking for firewall?

eno
19 Jun, 2023, 15:45

yeah makes sense! I have one question maybe is stupide. When I execute the function who (url ) makes the call to this Database, Is it not the server itself (https:// .../v1)?

Drake
19 Jun, 2023, 16:41

It's a container on the server

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more