Solved

API call | exportPipeReport | I'not retrieving ID from json return

  • 28 July 2022
  • 2 replies
  • 180 views

Userlevel 4

 

Hi!

 

I’m trying to recover one specific info from a POST that i’ve done.

import requests
import json

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

payload = {"query": "mutation {exportPipeReport(input: { pipeId:\"XXXXX\", pipeReportId: \"XXXXX\"}) {pipeReportExport {id}}}"}
headers = {
"Authorization": "Bearer XXXX",
"Content-Type": "application/json"
}

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

Id_relatorio = data['data']

print(Id_relatorio)

I’m using python 3, but i can only recover the entire data: 

{
"data": {
"exportPipeReport": {
"pipeReportExport": {
"id": "302968765"
}
}
}
}

 

Do you have any idea how to manipulate the returning JSON, with python, in order to print only the “ID” info?

 

Thanks!

icon

Best answer by João Nicolete 29 July 2022, 16:33

View original

This topic has been closed for comments

2 replies

Userlevel 4

WOW! Tks! Worked fine!

Userlevel 2

Hi! 

You can do it like this: 

 Id_relatório = data['data']['exportPipeReport']['pipeReportExport']['id']

That way you will retrieve just the id value from the JSON. 

Let us know if that works or if you run throught any problems.