I am trying to create a simple HTTP request to a Google Cloud function, so when I call the Google Cloud URL a mail will be sent via the Mailgun API.
Below is the very basic Mailgun code I used in PyCharm to test the connection and everything is working fine. When I run this function on my computer I'll receive an email in my inbox.
import requests
def send_simple_message():
return requests.post(
"https://api.eu.mailgun.net/v3/mg.my.url.com/messages",
auth=("api", "XXXXXxKEYxXXXXX"),
data={"from": "Name <name@mg.my.url.com>",
"to": "name@outlook.com",
"subject": "Hello You",
"text": "Testing some Mailgun awesomness!"})
send_simple_message()
As soon as I create an HTTP function in GCP and copy/paste the same code there I get an error. The only difference is I added requests==2.21.0 to the requirements.txt file. I believe this tells Google Cloud to include the requests module in Python.
Error I'm getting from logfile:
Error: function crashed. Details: 'Request' object has no attribute 'post'
Do I need to add another module to Python?
