我正在尝试以包含JSON的POST请求的形式将触发器发送到Zapier Webhook。如果我只是通过本地python脚本发送POST请求,则效果很好。
我想做的是创建一个RESTful API,当调用create-row-in-gs端点时,该触发器将触发Zapier Webhook。
如您所见,我正在向Hasura集群发送POST请求API调用。但是,我得到的不是“ 200 OK成功”,而不是“ 200 OK成功”,这意味着该请求被视为GET请求而不是POST请求。
test.py
#Python 3 Script to send a POST request containing JSON
import json
import requests
api_url = 'http://app.catercorner16.hasura-app.io/create-row-in-gs'
create_row_data = {'id': '1235','name':'Joel','created-on':'27/01/2018','modified-on':'27/01/2018','desc':'This is Joel!!'}
r = requests.post(url=api_url, data=create_row_data)
print(r.status_code, r.reason, r.text)
Run Code Online (Sandbox Code Playgroud)
server.py(在Hasura群集上运行)
from src import app
from flask import jsonify,request,make_response,url_for,redirect
from json import dumps
from requests import post
url = 'https://hooks.zapier.com/hooks/catch/xxxxx/yyyyy/'
@app.route('/create-row-in-gs', methods=['GET','POST'])
def create_row_in_gs():
if request.method == 'GET':
return make_response('failure')
if request.method == 'POST':
t_id = request.json['id']
t_name = …Run Code Online (Sandbox Code Playgroud)