Coder Social home page Coder Social logo

Comments (5)

arnaudbreton avatar arnaudbreton commented on August 22, 2024

Hi @sicoa,

Thanks for reaching out here again. We're glad to see you're exploring deeper and deeper our API.

About your first question, have you already visited the dedicated section for this method in our API guides? It's here http://dev.mailjet.com/guides/#managecontactslists

About your second question, can you post the full code (adding formatting, thanks to Github flavoured Markdown). Here, I'm missing the part where you're actually execute the request via client.post(request).

Thanks!

from mailjet-apiv3-java.

sicoa avatar sicoa commented on August 22, 2024

Thank you for the quick reply Mr Breton

I would like to see how to use the java wrapper for these functions.
Maybe i am doing something wrong.
The client.post(request) is the exact next line :) I just omitted it considering the call granted, my bad.

Request:
{"Action":"","Filters":"{}","Action ID":0,"Resource":"contact","ID":1504485533,"Body":"{"ContactsLists":[{"Action":"addforce","ListID":"1"}]}"}
Response
{"Status":405,"ErrorInfo":"","ErrorMessage":"Method not allowed","StatusCode":405}

Code (is this correctly stated?):

request = new MailjetRequest(Contact.resource, id)
                                    .property(ContactManagecontactslists.CONTACTSLISTS, new JSONArray()
                                            .put(new JSONObject()
                                                    .put("ListID", listsArray[i])
                                                    .put("Action", action)));
response = cl.post(request);

from mailjet-apiv3-java.

arnaudbreton avatar arnaudbreton commented on August 22, 2024

@sicoa, you're welcome!
Thanks for taking the time to format it correctly, appreciated!

After digging deeper here, I've figured out what's going wrong here: the resource to invoke here is not Contact but ContactManagecontactslists. This code snippet to build the request object should then work better:

request = new MailjetRequest(ContactManagecontactslists.resource, ID)
                .property(ContactManagecontactslists.CONTACTSLISTS, new JSONArray()
                                 .put(new JSONObject()
                                         .put("ListID", "ListID_1")
                                         .put("Action", "addnoforce"))
                                 .put(new JSONObject()
                                        .put("ListID", "ListID_2")
                                        .put("Action", "addforce")));

Please let us know how this works for you!

Best,
Arnaud.

from mailjet-apiv3-java.

sicoa avatar sicoa commented on August 22, 2024

It did work alright!
It needs the ID of the contact referring to ContactManagecontactslists.resource. That was the missing piece. I suppose this line of thought applies to the rest of the similar calls.
Thank you very much for your accurate help.
Best wishes
sicoaDev

from mailjet-apiv3-java.

arnaudbreton avatar arnaudbreton commented on August 22, 2024

@sicoa, glad to hear it works!

Yes, the general logic of our wrapper is to consider action endpoints (like here /contact/:id/managecontactslists as a resource. This logic can indeed be applied to the other available resources' actions.

Best,
Arnaud.

from mailjet-apiv3-java.

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.