Hello, @vicente-lemes. How are you?
Congratulations on starting your studies in Python.
Instead of using updatecard and then using updatecardfield. You can use only the updateCardField and pass the information you want to update.
Example:
variables = {
"cardId": xxxxx,
"fieldId": "descri_o",
"newValue": "teste"
}
{
updateCardField(input: {
card_id: $cardId,
field_id: $fieldId,
new_value: $newValue
}) {
success
}
}
Here is our website for developers: Pipefy Developers
Hello, @vicente-lemes. How are you?
Congratulations on starting your studies in Python.
Instead of using updatecard and then using updatecardfield. You can use only the updateCardField and pass the information you want to update.
Example:
variables = {
"cardId": xxxxx,
"fieldId": "descri_o",
"newValue": "teste"
}
{
updateCardField(input: {
card_id: $cardId,
field_id: $fieldId,
new_value: $newValue
}) {
success
}
}
Here is our website for developers: Pipefy Developers
Thanks Felipe
I tried but it returns and error:
{'errors': '{'message': 'Variable $cardId is used by but not declared', 'locations': c{'line': 4, 'column': 14}], 'path': ,'mutation', 'updateCardField', 'input', 'card_id'], 'extensions': {'code': 'variableNotDefined', 'variableName': 'cardId'}}, {'message': 'Variable $fieldId is used by but not declared', 'locations': c{'line': 5, 'column': 15}], 'path': ,'mutation', 'updateCardField', 'input', 'field_id'], 'extensions': {'code': 'variableNotDefined', 'variableName': 'fieldId'}}, {'message': 'Variable $newValue is used by but not declared', 'locations': c{'line': 6, 'column': 16}], 'path': ,'mutation', 'updateCardField', 'input', 'new_value'], 'extensions': {'code': 'variableNotDefined', 'variableName': 'newValue'}}]}
I still can’t figure out how to get out of this. If I try what you suggested it says that my variables are not declared, if I try what I showed in the first post it shows that ‘type mismatch’ error
My code:
import requests
import child_relation_pipefy_v2
import bearer
url = "https://api.pipefy.com/graphql"
bearer_token = bearer.token
extracted_id = child_relation_pipefy_v2.extracted_id
def graphql_update(query, variables=None):
headers = {
"accept": "application/json",
"content-type": "application/json",
"authorization": f"Bearer {bearer_token}"
}
payload = {"query": query, "variables": variables}
response = requests.post(url, json=payload, headers=headers)
return response.json()
variables = {
"cardId": extracted_id,
"fieldId": "descri_o",
"newValue": "teste"
}
update_card_mutation = """
mutation {
updateCardField(input: {
card_id: $cardId,
field_id: $fieldId,
new_value: $newValue
}) {
success
}
}
"""
response = graphql_update(update_card_mutation, variables=variables)
print(response)
Result:
{'errors': r{'message': 'Variable $cardId is used by but not declared', 'locations': t{'line': 4, 'column': 14}], 'path': ''mutation', 'updateCardField', 'input', 'card_id'], 'extensions': {'code': 'variableNotDefined', 'variableName': 'cardId'}}, {'message': 'Variable $fieldId is used by but not declared', 'locations': t{'line': 5, 'column': 15}], 'path': ''mutation', 'updateCardField', 'input', 'field_id'], 'extensions': {'code': 'variableNotDefined', 'variableName': 'fieldId'}}, {'message': 'Variable $newValue is used by but not declared', 'locations': t{'line': 6, 'column': 16}], 'path': ''mutation', 'updateCardField', 'input', 'new_value'], 'extensions': {'code': 'variableNotDefined', 'variableName': 'newValue'}}]}
The only way I made it work is if I fix the values of the card_id, field_id and new_value
Hi, @vicente-lemes. How are you?
The way to declare variables inside GraphQL is like this. You'll need to make this adjustment so that the error you showed about variables is resolved.
mutation updateCardField( $cardId: ID!,$fieldId:ID!, $newValue: eUndefinedInput]) {
updateCardField(input: {
card_id: $cardId,
field_id: $fieldId,
new_value: $newValue
}) {
success
}
}
Anything, I'll be here!
Hi, @vicente-lemes. How are you?
The way to declare variables inside GraphQL is like this. You'll need to make this adjustment so that the error you showed about variables is resolved.
mutation updateCardField( $cardId: ID!,$fieldId:ID!, $newValue: uUndefinedInput]) {
updateCardField(input: {
card_id: $cardId,
field_id: $fieldId,
new_value: $newValue
}) {
success
}
}
Anything, I'll be here!
It worked, thanks!
Funny how it looks obvious only after you told me how to do it