Back

[SOLVED] An internal curl error has occurred within the executor! Error Msg: Could not resolve host:

  • 1
  • Self Hosted
  • Functions
  • Apple
Rajat
6 Dec, 2023, 04:58

One thing in the development docs that I've noticed -> https://appwrite.io/docs/products/functions/development#response Here in Swift language, "return context.res.send("<h1>This is an HTML response</h1>", 200, [ "content-type": "text/html" ])" This line when executed throws an error saying that "Missing parameters statusCode: and headers: "

TL;DR
The user had an issue with an internal curl error related to resolving the host. The issue was resolved with the help of another user. The user then faced an issue with accessing resources in their Swift Package using Bundle.module. They tried using Bundle(for: ) but it didn't work. A workaround solution was suggested, which involved copying open runtime files into the package and compiling with Xcode or `xcodebuild`. The user also had questions about testing the function and accessing headers and body. The issue with accessing individual values from the body was caused by the input not being a JSON serializable string. The user encountered syntax errors while trying to
Rajat
6 Dec, 2023, 04:59

I added statusCode: and headers: parameters in functions so it builds fine...But again does not execute.

Rajat
6 Dec, 2023, 12:34

Did that, and the first point of failure is me trying to get data from context.req.body Can you help with this? because the way mentioned in docs is throwing syntax errors while deploying.

Drake
6 Dec, 2023, 12:38

What error exactly?

Rajat
6 Dec, 2023, 12:40

It cannot seem to find NSJSONSerialization. Which is true because it is renamed to just JSONSerialization

Drake
6 Dec, 2023, 12:40

So this is a runtime error and it's because the input isn't a JSON serializable string

Rajat
6 Dec, 2023, 12:43

if I pass a json data like this one -> {"text": "Hello world from json", "from": "567898765678"}, then what should be the way for me to get that in my funtion?

When I straight up write context.log(context.req.body), it prints the above json as expected...but If I try to get individual value like context.req.body["text"]...It gives the error that context.req.body does not supports subscripts

Drake
6 Dec, 2023, 12:43

How are you executing the function?

Rajat
6 Dec, 2023, 12:44

Via console, and passing the headers and body

Drake
6 Dec, 2023, 12:44

What headers?

Rajat
6 Dec, 2023, 12:45

Authorization

Rajat
6 Dec, 2023, 12:45

but that is just for me see if i can get those data or not

Rajat
6 Dec, 2023, 12:45

headers I can get by just context.req.headers["KeyName"] and it works great

Rajat
6 Dec, 2023, 12:46

but not working with body

Drake
6 Dec, 2023, 12:46

Body will be a string unless Appwrite knows the content is supposed to be JSON via the headers (content-type: application/json)

Rajat
6 Dec, 2023, 12:47

Oh okay will add that too in headers

Rajat
6 Dec, 2023, 12:48

Also silly question, but the only way I can test if my function compiles is by deploying to Appwrite and then waiting for the results?

Drake
6 Dec, 2023, 12:51

You can set up a local instance of Appwrite and deploy to that.

Technically, you can also run the build commands manually using open runtimes, but it's a little complicated.

We plan to make local development easier in the future

Rajat
6 Dec, 2023, 12:56

Sure. Thanks

Triple Gelato
6 Dec, 2023, 16:27

A hacky quick way to compile locally is to copy the open runtime files into your package and add Vapor as dependency, then you can compile your function package with Xcode or xcodebuild. When deploying just ignore or delete the runtime files.

Rajat
7 Dec, 2023, 10:30

The deployment fails when I try to bundle resources with my Swift Package....

So basically I added resource in my target and tried accessing them using Bundle.module...But the error is thrown saying "type 'Bundle' has no member 'module'"....Now one reasoning I came up with is that The Bundle.module property is available in Swift packages starting from Swift 5.3 (Although I'm working with 5.8). So, I tried to use Bundle(for: ) to get ref to bundle...But that does not seem to get the path to file either.

The resource is an html file here.

Triple Gelato
7 Dec, 2023, 17:01

Did you list the html file in Package.swift?

Rajat
10 Dec, 2023, 09:15

Yes I did. Some other work came so this was on hold. So yeah, I listed it as well

Rajat
11 Dec, 2023, 06:39

Labelling this whole issue -> SOLVED as with the original problem I faced, @Steven helped me sort it out.

Rajat
11 Dec, 2023, 06:40

[SOLVED] An internal curl error has occurred within the executor! Error Msg: Could not resolve host:

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