Skip to main content

Hello, all.I'm trying to get all cards from a pipe consuming the GraphQL API with Python.

Everything was working until I had to use pagination to get more than 50 cards.Below, the code that is returning errors:url = ""https://api.pipefy.com/graphql""payload = ""{\""query\"": \""{ allCards(pipeId: XXXXXX, first: 50, after: \""WyIwLjYyNSIsIjIyOS4wIiw1MzExMzQ5M10=\"") { edges { node { id title phases_history { phase { name } firstTimeIn lastTimeOut } } cursor } pageInfo { endCursor hasNextPage } } }\""}""headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <MY-AUTH-KEY>'
}response = requests.request(""POST"", url, data=payload, headers=headers)
response_body = response.text
print(response_body)Below, the error that returns:{""errors"":[{""message"":""Error parsing GraphQL request: error decoding JSON. This likely means that the GraphQL request was malformatted.: invalid character 'W' after object key:value pair""}]}If I just remove the
, after: \""WyIwLjYyNSIsIjIyOS4wIiw1MzExMzQ5M10=\


It works again, but retrieving only 50 cards.Could please, someone help me?
Thank you very much.

Hello Rosana, 

 

I believe the escaping is wrong in your payload var.   

 

Here an example in Python with pagination:

import requests

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

payload = {"query": "{ allCards(pipeId: 123456, first: 5, after:\"WyIyLjc1IiwiMC4wIiwzNjAwODc0Ml0\") { edges { node { id title fields { name report_value updated_at value } } } pageInfo { endCursor } } }"}
headers = {
"authorization": "Bearer TOKEN",
"content-type": "application/json"
}

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

print(response.text)

 

 

If you have any doubts about escaping, our Developers page has a Console to help you on that :wink:

https://developers.pipefy.com/reference#graphql-endpoint

 

 


Reply