import requests
import json
url = "https://api.pipefy.com/graphql"
# Static query works
#query = """mutation{createCard( input: { pipe_id: 301421136 fields_attributes:[ {field_id: \"company_name\", field_value: \"Static Test Company\"} ] } ){ card { id title } } }"""
# Variable query to test
variables = {
"company_name": "My Test Company"
}
query = """mutation($company_name: String){ createCard( input: { pipe_id: 301421136 fields_attributes: [{field_id: \"company_name\", field_value: $company_name} ] } ) { card { id title } } }"""
headers = {
"content-type": "application/json",
"authorization": "Bearer token here"
}
# Static query work
#response = requests.request("POST", url, json={"query": query}, headers=headers)
response = requests.request("POST", url, json={"query": query, "variables": variables}, headers=headers)
print(response.text)
I’m using the above code to try and create a card using a variable (company_name). The variable is a string (although in the api its listed as short_text).
I keep getting the following error message:
"errors":r{"message":"Type mismatch on variable $company_name and argument field_value (String / gUndefinedInput])","locations":n{"line":1,"column":121}],"path":t"mutation","createCard","input","fields_attributes",0,"field_value"],"extensions":{"code":"variableMismatch","variableName":"company_name","typeName":"String","argumentName":"field_value","errorMessage":"Type mismatch"}}]}
Does anybody know how to solve this? I’m dying here :(