Error while trying to perform an HTTP request with Python

Hi, i’m very new to snipes and now a little frustraded :smiley: , i tryed a simple http request with an python snipcode but after 3 hours now i must aks…

import urllib.request
contents = urllib.request.urlopen(“ip/domain/test”).read()
<

is this posible? i dont had any luck to get this to work … help would be nice :slight_smile:
Greets

Hi @rbaldauf,

Your issue is more related to Python than it is to Snips.
It is possible to perform a simple HTTP request with python’s standard library.

import urllib.request

url = "https://a.website.com"
result = urllib.request.urlopen(url).read().decode('utf-8')
print(result)

Cheers.

Hmpf this will still noit work. Error msg in “sam watch”
[16:36:51] [Dialogue] session with id ‘1bbc9249-1c61-464c-a490-d93c0c481436’ was ended on site default. The session was ended because one of the component didn’t respond in a timely manner

The message : The session was ended because one of the component didn’t respond in a timely manner is not an error.
It means that the action code did not ended or continued the ongoing dialogue session.

Please refer to the hermes-python documentation on how to manage dialogue session.

still no luck with this. i dont understand why there is no “error” but the request will also not be send :confused: any other ideas ? :slight_smile:

Greets

Hi, I try something similar. Did you succeed in the meanwhile. Would be interested to hear how it worked.

You can’t import additional modules with snippets, AFAICT. Use a “git” action instead, and then you can do whatever you want. I suggest looking at snipskit (https://github.com/koenvervloesem/snipskit) if you want to write in python. It’s developed by another user on here.

Thank you! Saves me from fiddling around.

Any new ideas? No luck :frowning: