Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API gives incorrect/delayed results #53

Open
plainlystated opened this issue Apr 6, 2017 · 0 comments
Open

API gives incorrect/delayed results #53

plainlystated opened this issue Apr 6, 2017 · 0 comments

Comments

@plainlystated
Copy link

I'm getting an error when querying properties of recently created lists: After I create a list, I then query for the list of lists (CreateSend::Client#lists) and the recently-created list is missing most of the time.

This rake task consistently exhibits the issue for me:

require 'createsend'

namespace :campaign_monitor do
  task :demo do
    auth = {api_key: API_KEY}
    client_id = CreateSend::CreateSend.new(auth).clients.tap do |cs|
      raise if cs.size != 1
    end.first['ClientID']

    client = CreateSend::Client.new(auth, client_id)

    p [:available_lists, client.lists.map(&:Name)]
    # (empty list to start)

    20.times do |i|
      puts "Creating list#{i}"
      list_id = CreateSend::List.create(auth, client_id, "list#{i}", "https://localhost", false, "https://localhost")

      sleep 10 

      p [:available_lists, client.lists.map(&:Name)]
      # Even after 10 seconds, still missing....

      puts
    end
  end
end

Output:

[:available_lists, []]
Creating list0
[:available_lists, []]

Creating list1
[:available_lists, []]

Creating list2
[:available_lists, ["list0", "list1", "list2"]]

Creating list3
[:available_lists, ["list0", "list1", "list2"]]

Creating list4
[:available_lists, ["list0", "list1", "list2"]]

Creating list5
[:available_lists, ["list0", "list1", "list2", "list3", "list4", "list5"]]

Creating list6
[:available_lists, ["list0", "list1", "list2", "list3", "list4", "list5"]]

Creating list7
[:available_lists, ["list0", "list1", "list2", "list3", "list4", "list5"]]

.... (etc, same 30-second delay for the rest) ...

I can, however, grab the list ID that comes back from the CreateSend::List.create call, and use it to delete the list from the server (presumably I could do other things with it via the API).

This behavior definitely feels unintuitive, so some docs about what my expectations should be would be nice at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant