我想通过发布请求启动流程运行。
curl -X POST \
-H "Content-Type: application/json" \
-d '{"query": "{ flow{id} }"}' \
http://localhost:4200/graphql
以上是与api的基本交互。
突变查询:
mutation {
create_flow_run(
input: {flow_id: "cabfecfb-8ce7-47aa-9ba4-c181dbf4a430",
parameters: "{ \"points_y_column\": \"lat\", \"points_x_column\": \"lon\", \"out_format\": \"CSV\"}"}
) {
id
}
}
此查询适用于 Graphq 界面。以“\”为前缀的参数中的引号。
我如何将查询放入字符串中。喜欢:
-d '{"query": "<my_mutation_query>"}'
Python 方法
headers = {"Content-Type": "application/json",
'tenant_id': 'f874d20a-ba21-4c7f-1111-d43cbf4751e9'}
query = """mutation {
create_flow_run(
input: {flow_id: "cabfecfb-8ce7-47aa-9ba4-c181dbf4a430",
parameters: "{ \"points_y_column\": \"lat\", \"points_x_column\": \"lon\", \"out_format\": \"CSV\"}"}
) {
id
}
}"""
r = requests.post(req_url , json = {"query": query}, headers=headers)
我收到以下错误:
b'{"errors":[{"message":"Syntax Error: Expected :, found String \\": \\"","locations":[{"line":4,"column":44}],"extensions":{"code":"GRAPHQL_PARSE_FAILED"}}]}\n'