campaignmonitor/createsend-python

client.campaigns() TypeError: 'type' object is not iterable

Opened this issue · 4 comments

hello

when i run

cs = CreateSend(auth)

clients = cs.clients()
campaign_ids = cs.clients()

for cl in clients:
print("Client: %s" % cl.Name)
client = Client(auth, cl.ClientID)
print("- Campaigns:")
for cm in client.campaigns():
print(" - %s" % cm.Subject)
print(" - %s" % cm.CampaignID)

i have this issue

File "C:\Users\eguevara\AppData\Local\Temp/ipykernel_17348/3998498663.py", line 1, in
for i in client.campaigns():

TypeError: 'type' object is not iterable

I had the same issue. An older installation with createsend pip 6.1.2 module works well, with createsend 7.0.0 the same code doesn't work anymore. According to the release notes:

Breaking: 'client.campaigns' now returned an object to support pagination (use .Results to get the array of campaigns)

for cm in client.campaigns().Results:

This works !

It's happening to me as well. Looks like this wrapper isn't updated. Anyone lucky in acquiring list of campaignIds?

It's happening to me as well. Looks like this wrapper isn't updated. Anyone lucky in acquiring list of campaignIds?

As said, use .Results

for cl in clients:
client = Client({'api_key': ''}, cl.ClientID)
for cm in client.campaigns().Results:
campaign = Campaign({'api_key': ''}, cm.CampaignID)
cx=campaign.summary()

It's happening to me as well. Looks like this wrapper isn't updated. Anyone lucky in acquiring list of campaignIds?

As said, use .Results

for cl in clients: client = Client({'api_key': ''}, cl.ClientID) for cm in client.campaigns().Results: campaign = Campaign({'api_key': ''}, cm.CampaignID) cx=campaign.summary()

Hi Thanks speedy! Turns out it's because i used a differnt funciton to get client:

auth = (username, password)
...
client = Client(auth, cl.ClientID)

changed it to client = Client({'api_key': ''}, cl.ClientID) and now it's working

Thanks for the headsup