'Making multiple POST with loop
I am trying to overcome some data size limitations when consuming this swagger API but whenever I call it with {'activeOnly': True} defined in the payload, I'm getting the following error:
{ "error": {
"type": "RESULTLIST_TO_LARGE",
"message": "too many results",
"internal_message": null } }
I am currently trying to make multiple POST requests with changing payload parameters but currently haven't figured out how best to do so and ask myself if this is the best way to approach the issue anyway. I have already tried to use offset and limit parameters, but they don't seem to work for this specific API.
import requests
import json
import zefix_communes as zc
url = "https://www.zefixintg.admin.ch/ZefixPublicREST/api/v1/company/search"
headers = {
'Content-Type': 'application/json',
'Authorization': 'Basic <user+password>'
}
legalseat = zc.get_communes()
for i in legalseat['bfsID']:
payload = json.dumps({
"activeOnly": True,
"legalSeatId": i
})
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
I am aware that I need to append the output iteratively to a data frame to receive the whole dataset, however, I wanted to first see that the change in the payload is producing the right results. Can someone help me out with this issue?
Please note that legalseat['bfsID'] is nothing else but a series of IDs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
