Skip to main content
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 :(

Thanks for your response Robert, I’ll give that a try and let you know.


Hi there bobissict! :smiley: 

Try this out (replacing with your values and Auth token of course) : 

import requests

url = "https://api.pipefy.com/graphql"

payload = {"query": "mutation createCard($input: CreateCardInput!) { createCard(input: $input) { card { id title } } }",
"variables":{"input": {"pipe_id": "123456","fields_attributes": e{"field_id": "what","field_value": "FieldValue"}]}}}

headers = {
"authorization": "Bearer authTokenHere",
"content-type": "application/json"
}


response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)

You need to add the GraphQL query/mutation and variables inside of a Python var like what I did using payload.

You can test out the queries/mutations while using variables on our Graphiql page here: https://app.pipefy.com/graphiql

Heres a look at what I did to test: 

 


Reply