Skip to main content

Hi! I'm working in a python script that read some fields from all cards from a pipe and them write it to pandas in Python. The main idea is to iterate through all key values from json list.
Here's my code:

import requests
import jsonurl = ""https://api.pipefy.com/graphql""payload = ""{\""query\"":\""{ allCards (pipeId:127682, first:50) { edges { node { id title fields { name report_value updated_at value } } } }} \""}""
headers = {
'authorization': ""Bearer ""my_token"""",
'content-type': ""application/json""
}response = requests.request(""POST"", url, data=payload, headers=headers)
print(response.text)Since here, all it's ok.But when I try to parse it with json with this code:json_dic=json.loads(response.text)for key in json_dic:
print (key,"":"",json_dic[key])I just got an another list like the first ""print"", it seems that ""response.text""

is not a dict object, so when I parse it with json.loads, script can't identify the keys and separate them.Whats going wrong?Thx!

Hey Nigel, 

 

It’s necessary to access the dictionary elements before iterate it. 

 

You can access the edges

>'data']d'allCards']a'edges']d0]

 

Or node fields: 

/'data']['allCards']l'edges']'0]g'node']['fields']f0]

 

 

Here an example in Python:

import requests
import json


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

payload = "{\"query\":\"{ allCards (pipeId:127682, first:50) { edges { node { id title fields { name report_value updated_at value } } } }}\"}"
headers = {
'authorization': "Bearer YOUR TOKEN",
'content-type': "application/json"
}

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

dic=json.loads(response.text)o'data']t'allCards']a'edges']]0]e'node']0'fields'][0]

for key in dic:

print(key, ":", dic,key])

 


Hi all, 

What about to list ALL cards? not firts 50th.

 

I`ve trying using first, last, after, before… nothing that helps to list all cards or to ‘paginate’.

 

Any idea? 

 


Hey @m.sabadini ,  

 

We need to use pagination in order to keep Pipefy infrastructure safe. 

 

To paginate you need to use pageInfo attribute. 

 

 

{
allCards(pipeId: 987654) {
edges {
node {
id
}
}
pageInfo {
endCursor
}
}
}

 

 

In the response payload you’ll get a string to use in your next query: 

 

      ],
"pageInfo": {
"endCursor": "WyIyLjgyODEyNSIsIjI5MC4wIiwzNzc4MzQ5MDld"
}
}
}
}

 

 

Like this: 

 

{
allCards(pipeId: 987654, after:"WyIyLjgyODEyNSIsIjI5MC4wIiwzNzc4MzQ5MDld") {
edges {
node {
id
}
}
pageInfo {
endCursor
}
}
}

 

 

Hope it helps you  =D 


Super tks Marcos! 

 

that is it! It works like a charm...


Reply