Reputation: 169
I am attempting to deploy a basic python function which calls an api using an HTTP trigger through Google Functions (browser-editor).
Here's the function I'm trying to deploy:
import requests
import json
def call_api():
API_URL = 'https://some-api.com/v1'
API_TOKEN = 'some-api-token'
result = requests.get(API_URL+"/contacts?access_token="+API_TOKEN).json()
print(result)
call_api()
My requirements.txt contains:
requests==2.21.0
However, every time I try to deploy the function, the following error occurs:
Unknown resource type
What am I doing wrong? The function works just fine on my local machine.
Upvotes: 1
Views: 525
Reputation: 2140
Please refer to Writing HTTP Functions for more information. This is what comes to my mind when looking at your code:
request
parameter (def call_api(request):
)call_api()
at the end of the file will call the function only locally, CFs don't need thisMake sure you are deploying using gcloud functions deploy call_api --runtime python37 --trigger-http
Upvotes: 1