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

How can I get campaign ID from newsletter #69

Closed
hirokipf opened this issue Apr 19, 2016 · 2 comments
Closed

How can I get campaign ID from newsletter #69

hirokipf opened this issue Apr 19, 2016 · 2 comments

Comments

@hirokipf
Copy link

Hello,

I am trying to get campaign ID from newsletter to retrieve statistics.
But newsletter data does not include campaign ID.

How can I get campaign ID?
Am I missing something?

Thanks!

Here is my code :

create_newsletter_param = {
  Locale: "ja_JP",
  Sender: "Me",
  SenderEmail: "test@mydomain.com",
  Subject: "test mail",
  ContactsListID: 1234,
  Title: "Test campaign"
}
newsletter = Mailjet::Newsletter.create(create_newsletter_param)
=> #<Mailjet::Newsletter:0x007f6e1cd36170
 @attributes=
  {"persisted"=>false,
   "Locale"=>"ja_JP",
   "Sender"=>"Me",
   "SenderEmail"=>"test@mydomain.com",
   "Subject"=>"test mail",
   "ContactsListID"=>1234,
   "Title"=>"Test campaign",
   "ax_fraction"=>0,
   "ax_fraction_name"=>"",
   "callback"=>"",
   "contacts_list_id"=>1234,
   "created_at"=>Tue, 19 Apr 2016 04:46:36 +0000,
   "delivered_at"=>"",
   "edit_mode"=>"tool",
   "edit_type"=>"full",
   "footer"=>"default",
   "footer_address"=>"",
   "footer_wysiwyg_type"=>0,
   "header_filename"=>"",
   "header_link"=>"",
   "header_text"=>"",
   "header_url"=>"",
   "id"=>20045,
   "ip"=>"",
   "is_handled"=>false,
   "is_starred"=>false,
   "is_text_part_included"=>false,
   "locale"=>"ja_JP",
   "modified_at"=>"",
   "permalink"=>"default",
   "permalink_host"=>"",
   "permalink_wysiwyg_type"=>0,
   "politeness_mode"=>0,
   "sender"=>"Me",
   "sender_email"=>"test@mydomain.com",
   "sender_name"=>"",
   "status"=>0,
   "subject"=>"test mail",
   "test_address"=>"",
   "title"=>"Test campaign",
   "url"=>""},
 @persisted=true>
@hirokipf hirokipf changed the title How can I get campaign ID How can I get campaign ID from newsletter Apr 19, 2016
@WeshGuillaume
Copy link
Contributor

WeshGuillaume commented Apr 19, 2016

Hey @hirokipf !

You can get a campaignID associated with the newsletter by making a GET campaign/mj.nl=<newsletter id> call.

With this ruby client, you will have to do it like this for instance:

campaign = Mailjet::Campaign.find('mj.nl=20160')
p campaign

@hirokipf
Copy link
Author

It worked!!
Thanks for the quick reply!

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

2 participants