-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
The function returns the same result no matter the values.
api_id = ...
api_secret = ...
address_book_id = ...
api = PySendPulse(api_id, api_secret, storage_type="FILE", token_file_path=...)
# These all return the same result:
api.get_emails_from_addressbook(address_book_id, limit=1, offset=0)
api.get_emails_from_addressbook(address_book_id, limit=10, offset=0)
api.get_emails_from_addressbook(address_book_id, limit=10, offset=10)
Investigation showed that the most probable reason is that PySendPulse.__send_request
serializes
params
to json for any method:
params = json.dumps(params) |
whereas address books emails api endpoint seems to expect normal GET-params now:
import json
import requests
token = ...
address_book_id = ...
url = f"https://api.sendpulse.com/addressbooks/{address_book_id}/emails"
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
params = { 'limit': 10, 'offset': 0 }
# This returns 10 emails, as expected
response = requests.get(url, headers=headers, params=params)
print(len(response.json()))
# This returns 100 emails, not as expected:
response = requests.get(url, headers=headers, params=json.dumps(params))
print(len(response.json()))
Metadata
Metadata
Assignees
Labels
No labels