Solved

API not returning correct number of People in a page

  • 6 July 2023
  • 1 reply
  • 15 views

Hello everyone,

i have a tool in Python for automatically, periodically grabbing People from Copper.

This tool worked for years, but all of a suddon one of the pages has 199 items instead of 200. (was the first, now seems to be the second?)

Note the total number of People in Copper is around 21k so i use to have many pages.

 

CONTATTI_PER_PAG=200

contaPagg = 0

contatti = {}

nrProgressivoContattiLetti = 0

TOKEN_OWNER_EMAIL = 'sales@extravega.com'

while contaPagg < NR_MAX_PAGG or NR_MAX_PAGG == 0:

contaPagg += 1
url = 'https://api.copper.com/developer_api/v1/people/search'
body = {
"page_size": CONTATTI_PER_PAG,
"sort_by": "date_modified",
"sort_direction": "desc",
"page_number": contaPagg
}
headers = {'X-PW-AccessToken': API_KEY_TOKEN,
'X-PW-Application': 'developer_api',
'X-PW-UserEmail': TOKEN_OWNER_EMAIL,
'Content-Type': 'application/json'}
r = requests.post(url, headers=headers, params=body)
            contacts = r.json()
            nrContattiLettiPerPag = len(contacts)
            nrProgressivoContattiLetti += nrContattiLettiPerPag

 

My question is then: why the API started to deliver 199 items? 

 

Thanks

icon

Best answer by Michelle from Copper 6 July 2023, 18:29

View original

1 reply

Userlevel 7
Badge +7

Hi @Sales EV, thanks for posting! I’m gonna get the technical team to take a look. You’ll get an email from our system, followed by a response from one of my colleagues.

Reply