Giter Club home page Giter Club logo

Comments (10)

WeshGuillaume avatar WeshGuillaume commented on August 16, 2024

Hi @judemoutiez and thank you for using Mailjet !

A simple way to create a contact through the API is to use contactslist/:id/managecontact
Once you created a list, and you know its ID, you can create a contact within that list by using the Mailjet::Contactslist_managecontact class

Mailjet::Contactslist_managecontact.create(id: <your list id>, action: "addnoforce", email: "[email protected]", name: "Guillaume")

then you can check if it works via curl for example:

curl -X GET --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" https://api.mailjet.com/v3/REST/contact/?contactslist=<you list id> | python -m json.tool

I hope it helped !

Regards,
Guillaume from Mailjet

from mailjet-gem.

WeshGuillaume avatar WeshGuillaume commented on August 16, 2024

Hi @judemoutiez !

Please let me know if you didn't manage to make it work on your side, I'd take some more time to help you on the implementation. Otherwise, could you please close the issue ?

Regards,
Guillaume;

from mailjet-gem.

judemoutiez avatar judemoutiez commented on August 16, 2024

Hi Guillaume !

Thanks for your answer

I used the solution you gave me and it appears to be working, but not every single time.

When I test the line in the console, I manage to create a user, and if I try to create another one right after with another mail & name, I get this error:

"{ "ErrorMessage" : "Object properties invalid", "StatusCode" : 400, "ErrorInfo" : { "Email" : "MJ08 Property email is invalid: MJ03 A non-empty value is required", "Action" : "Invalid action: " } }"

The same seems to be happening on the website

Do you have an idea on what is happening ?

Thanks !

from mailjet-gem.

WeshGuillaume avatar WeshGuillaume commented on August 16, 2024

Hi !

I can't reproduce your error ! Can you paste a code snippet so I can try it on my side ? Here's what I've done so far:
screen shot 2015-09-07 at 15 08 18

from mailjet-gem.

judemoutiez avatar judemoutiez commented on August 16, 2024

Hi !

Here is what I get in the console

Loading development environment (Rails 4.1.4)
irb(main):001:0> Mailjet::Contactslist_managecontact.create(id: 16, action: "addnoforce", email: "[email protected]", name: "Julien")
=> #<Mailjet::Contactslist_managecontact:0x00000007e02520 @attributes={"persisted"=>false, "id"=>16, "action"=>"addnoforce", "email"=>"[email protected]", "name"=>"Julien", "contact_id"=>1489758118}, @persisted=true>
irb(main):002:0> Mailjet::Contactslist_managecontact.create(id: 16, action: "addnoforce", email: "[email protected]", name: "Julienbis")
Mailjet::ApiError: error 400 while sending #<RestClient::Resource:0x00000007e51800 @url="https://api.mailjet.com/v3/REST/contactslist/16/managecontact", @block=nil, @options={:public_operations=>[:post], :read_only=>nil, :user=>"api key", :password=>"api secret", :content_type=>"application/json"}> to https://api.mailjet.com/v3/REST/contactslist/16/managecontact with {}

"{ \"ErrorMessage\" : \"Object properties invalid\", \"StatusCode\" : 400, \"ErrorInfo\" : { \"Email\" : \"MJ08 Property email is invalid: MJ03 A non-empty value is required\", \"Action\" : \"Invalid action: \" } }"

Please see http://api.mailjet.com/0.1/HelpStatus for more informations on error numbers.

Thanks !

from mailjet-gem.

WeshGuillaume avatar WeshGuillaume commented on August 16, 2024

Hey Julien !

It is indeed really confusing. I don't know if it comes from you account or the rails/mailjet compatibility.. I still can't get the same error on my side. What output do you get if you issue this line in the terminal:

(do it twice with a different email and a different name)

curl -s -X POST --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" https://api.mailjet.com/v3/REST/contactslist/16/managecontact -H "Content-Type: application/json" -d '{"Action": "addnoforce", "Email": "[email protected]", "Name": "test github"}'

Thanks .
Guillaume ! :)

PS: remember not to publicly post your credentials (apikey/apisecret) ;)

from mailjet-gem.

WeshGuillaume avatar WeshGuillaume commented on August 16, 2024

Hey @judemoutiez !

I finally managed to reproduce your error. Thank you so much for the issue ! You might want to take a look at the rails_fix: branch. It looks like it fixes it. I just need to implement some more testing, but it should do the job !

Best,
Guillaume

from mailjet-gem.

judemoutiez avatar judemoutiez commented on August 16, 2024

Hello Guillaume !

Thank you very much, I'll have a loot at it :)

from mailjet-gem.

WeshGuillaume avatar WeshGuillaume commented on August 16, 2024

Hi @judemoutiez !

Please keep me up to date ! :)

Best,
Guillaume.

from mailjet-gem.

judemoutiez avatar judemoutiez commented on August 16, 2024

Works perfectly, thanks a lot !

from mailjet-gem.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.