我正在尝试部署一个基本的python函数,该函数通过Google Functions(浏览器编辑器)使用HTTP触发器调用api。
这是我要部署的功能:
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()
我的requirements.txt包含:
requests==2.21.0
但是,每次我尝试部署该功能时,都会发生以下错误:
Unknown resource type
我在做什么错?该功能在我的本地计算机上正常工作。
答案 0 :(得分:1)
有关更多信息,请参阅Writing HTTP Functions。这是我在查看您的代码时想到的:
request
参数(def call_api(request):
)call_api()
只会在本地调用该函数,CF不需要此确保使用gcloud functions deploy call_api --runtime python37 --trigger-http