mailjet / mailjet-apiv3-java Goto Github PK
View Code? Open in Web Editor NEW[API v3] Mailjet Java API Wrapper
Home Page: https://dev.mailjet.com
License: MIT License
[API v3] Mailjet Java API Wrapper
Home Page: https://dev.mailjet.com
License: MIT License
Greetings,
i am the colleague of Mr.Kaveiros, i will state the issues as they appear one by one respecting your great effort to solve them and our line of work. We shall mutually benefit :)
In the specific issue:
As i implemented and tried liststatistics, i was successful in getting results with GET by .List but unable to do so with the View part, the .Get function.
By straight try with WizTools and your URLs and my credentials, i fetched results with both ways.
The first lines of the errors i get at the View part is:
com.mailjet.api.client.MailJetApiCallException: Error '-4' - The MailJet API Client is incorrectly used.
Details: Identifier value must not be null.
I assume the implementation of .Get is broken. The same with .List works fine.
My code:
cl = MailjetUsersRest.createClient();
stat=cl.createCall(ListStatistics.Get).identifiedBy(ListStatisticsProperty.ID, id).execute();
Cheers
OD
Hi,
What is API_URL and where do I get it?
That is a bad document. Why do not you give us a specific example project?
Thanks,
Greetings once more
The reference states:
Access a given messagestatistics resource, use a GET request, providing the messagestatistics's ID value.
However, i do not know where to acquire the ID from. Messagestatistics List function unfortunately does not return an ID..
Thank you for any reply
Yours
sicoaDev
Greetings again
I cannot implement the View part both on CampaignStatistics and ApiKeyTotals.
There is only List to be used and as such, i cannot call .Get
ex.
cl.createCall(ApiKeyTotals.Get)
.identifiedBy(ApiKeyTotalsProperty.ID, id)
.execute();
or
cl.createCall(CampaignStatistics.Get)
.identifiedBy(CampaignStatisticsProperty.ID, id)
.execute();
Also, they both refer to other classes, which also puzzles me as to how to do that. In the above examples, .ID in both cases does not exist, nor for the second the "customvalue" as shown in the documentation. How do i call the totals and statistics from other class instances with their ID or other stat?
Thank you in advance
Remaining yours
When i try to update the Email of a sender object, i get "Error '400' - One or more arguments are missing or maybe mispelling. Details: Not allowed to change email address - "
However in the documentation, in Update, the attribute is Mandatory and not ReadOnly.
Same as Metasender issue:
When i try to Update a Sender by its ID, i get something like the following message but always maximum expected 1but it gets multiple objects:
"RETURNS: Error '-5' - The MailJet API Client is incorrectly used. Details: Returned object by MailJet API are more than expected. Maximum expected: 1; Returned: 4."
When i try to Update by Email i get the correct results.
Note: Viewing by ID returns a single result and not multiple.
2)Contact : @create: should be read-only stats: LastActivityAt, LastUpdateAt, UnsubscribedAt : Response = HTTP/1.1 401 Internal error: MJ19 Setting a value for property "LastActivityAt" is not allowed
3)ContactData : @update,@view,@delete: There is no "email" attribute to use as key for the functions, only ID.
BatchJob: @create: “Method” parameter takes specific values: by chance I tried successfully “Unknown”. Same with “Status” parameter[allows as tested: upload,abort ]. Can you please be specific?
BatchJob: What does the the following message means?
"ISSUE: Error '-1' - Unexpected error. Check the cause in the stack trace. Details: You are not allowed to post jobs for this AKID -"
Unsub: Read Only [ Type Boolean ]
At the API libary there seems to be no getter for this attribute
Hello,
For exemple, if there is a java.net.SocketTimeoutException, we get a nullpointer and the socketTimeoutException is logged in the console.
The MailjetClient should throwned all exceptions, as this we can catch and log them, and we can manage retries (depends on the error).
Dear Mailjet team,
thanks for the great Java API Wrapper!
When I tested it I recognized that the DELETE method in the MailjetClient class uses a GET operation instead, which does not fit your API description.
You can find it here: https://github.com/mailjet/mailjet-apiv3-java/blob/master/src/main/java/com/mailjet/client/MailjetClient.java#L199
Cheers,
Sven
Hello there
i have encountered another issue. I will explain:
I have been unsuccessful in creating a Newsletter in this way, with fixed values. Maybe i am doing something awfully wrong. Any insight will be greatly appreciated:
MailjetRequest request;
MailjetResponse response = null;
request = new MailjetRequest(Newsletter.resource)
.property(Newsletter.CONTACTSLIST, 1)
.property(Newsletter.LOCALE, "en-US")
.property(Newsletter.SENDER, "ovSPITItest")
.property(Newsletter.SENDEREMAIL, "[email protected]");
response = cl.post(request);
The request:
{"Filters":"{}","Action ID":0,"Resource":"newsletter","ID":0,"Body":"{\"Locale\":\"en-US\",\"Sender\":\"ovSPITItest\",\"SenderEmail\":\"[email protected]\",\"ContactsList\":1}"}
The errors when executing
response = cl.post(request); :
java.net.UnknownHostException: api.mailjet.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at com.turbomanage.httpclient.HttpResponse.<init>(HttpResponse.java:22)
at com.turbomanage.httpclient.AbstractHttpClient.readErrorStream(AbstractHttpClient.java:360)
at com.turbomanage.httpclient.AbstractHttpClient.doHttpMethod(AbstractHttpClient.java:227)
at com.turbomanage.httpclient.AbstractHttpClient.execute(AbstractHttpClient.java:173)
at com.turbomanage.httpclient.AbstractHttpClient.post(AbstractHttpClient.java:130)
at com.mailjet.client.MailjetClient.post(MailjetClient.java:154)
at com.sicoa.mailjet.rest.NewsletterClass.newsletterCreate(NewsletterClass.java:365)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:308)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:291)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1140)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:403)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
BasicRequestHandler.onError got
com.turbomanage.httpclient.HttpRequestException: java.net.UnknownHostException: api.mailjet.com
at com.turbomanage.httpclient.AbstractHttpClient.doHttpMethod(AbstractHttpClient.java:236)
at com.turbomanage.httpclient.AbstractHttpClient.execute(AbstractHttpClient.java:173)
at com.turbomanage.httpclient.AbstractHttpClient.post(AbstractHttpClient.java:130)
at com.mailjet.client.MailjetClient.post(MailjetClient.java:154)
at com.sicoa.mailjet.rest.NewsletterClass.newsletterCreate(NewsletterClass.java:365)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:308)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:291)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1140)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:403)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.UnknownHostException: api.mailjet.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source)
at com.turbomanage.httpclient.AbstractHttpClient.doHttpMethod(AbstractHttpClient.java:214)
... 50 more
Greetings
I have successfully created a Trigger by your specifications, and it returned even an ID: "Trigger created with ID: 75665139".
When i try to LIST or VIEW by the ID i get no results, only 204 No Content, using the same methodology that works 100% for other listing and viewing.
Any help as always would be welcome
Function LIST states: "At least one of the Open,Click,Unsub or Spam filters must be set" .
When i call LIST and have at least one of those filters true, i get always:
HTTP/1.1 500 Internal Server Error
Error '500' - Status returned when an unknow error occurs. Details: Unexpected database error during GET -
Hi
i cannot find the manycontacts class to call it, and also i cannot find the according Action class as well.
Do they exist?
If yes, can you please write specific name to call?
Kind regards
OD
Hey there,
great that you guys provided an API V3 Wrapper :)
However, I got some problems while running some tests to your API. I tried to output some messages I created with an account and got an NumberFormatException while parsing the JSON content for a Message. I looks like the Parser GSON Parser expects a number input instead of a String for the message status property.
Here is my sample code (which i tested with Java 8):
MailJetClientConfiguration config = new MailJetClientConfiguration()
.setBaseUrl("https://api.mailjet.com/v3/REST/")
.setDefaultApiKey("...")
.setDefaultSecretKey("...");
MailJetApiClient client = config.buildClient();
ResultSet<Message> messages = client.createCall(Message.List).execute();
And the Console output:
MailJetApiResponse execute called
Response = HTTP/1.1 200 OK [Date: Mon, 01 Sep 2014 15:35:15 GMT, Server: Apache, Content-Length: 2972, Connection: close, Content-Type: application/json]
Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: For input string: "opened"
at com.google.gson.internal.bind.TypeAdapters$6.read(TypeAdapters.java:219)
at com.google.gson.internal.bind.TypeAdapters$6.read(TypeAdapters.java:209)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:81)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
at com.google.gson.Gson.fromJson(Gson.java:803)
at com.google.gson.Gson.fromJson(Gson.java:768)
at com.google.gson.Gson.fromJson(Gson.java:717)
at com.mailjet.api.client.transform.impl.GsonDataTransformerImpl.fromStringResultSet(GsonDataTransformerImpl.java:55)
at com.mailjet.api.client.impl.MailJetApiCallImpl.getSingleResult(MailJetApiCallImpl.java:261)
at com.mailjet.api.client.impl.MailJetApiCallImpl.execute(MailJetApiCallImpl.java:96)
at mailjet.Test.main(Test.java:21)
Caused by: java.lang.NumberFormatException: For input string: "opened"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at com.google.gson.stream.JsonReader.nextInt(JsonReader.java:1178)
at com.google.gson.internal.bind.TypeAdapters$6.read(TypeAdapters.java:217)
... 15 more
Greetings
I am trying to send a Newsletter by immediate call:
request = new MailjetRequest(NewsletterSend.resource, id);
response = cl.post(request);
The newsletter i am trying to send is as folows, status 0 (DRAFT) is returned by "view" below.
The response i get is:
{"ErrorInfo":"","StatusCode":400,"Status":400,"ErrorMessage":"Missing content"}
The same happens when i try NewsletterTest call with the same Newsletter ID.
{
"Status": 200,
"Data": [{
"Ip": "",
"AXFraction": 0,
"ContactsListID": 1,
"Footer": "default",
"IsStarred": false,
"DeliveredAt": "",
"Sender": "MisterMailjet",
"Permalink": "default",
"Url": "",
"IsHandled": false,
"EditType": "full",
"Callback": "",
"AXFractionName": "",
"ID": 3____92,
"FooterWYSIWYGType": 0,
"CreatedAt": "2015-12-08T13:20:30Z",
"PolitenessMode": 0,
"HeaderLink": "",
"Subject": "Greetings from Mailjet",
"HeaderText": "",
"ModifiedAt": "",
"IsTextPartIncluded": false,
"PermalinkWYSIWYGType": 0,
"Locale": "en_US",
"HeaderUrl": "",
"TestAddress": "",
"SenderName": "",
"Title": "Friday newsletter",
"Status": 0,
"FooterAddress": "",
"EditMode": "tool",
"PermalinkHost": "",
"SenderEmail": "[email protected]",
"HeaderFilename": ""
}],
"Count": 1,
"Total": 1
}```
Thank you once more for any thoughts and pointing out if i am doing anything wrong
Remaining yours
sicoaDev
Those functions exist in the documentation but not on the API. Only availabilities are GET and LIST.
Is this correct? Will it be soon implemented?
Thank you in advance for any answer
Greetings again
2 issues:
I have a problem retrieving my campaigns.
I use the same code to retrieve successfully lets say Contacts, and when i try requesting Campaign.resource, i get empty result, even though i have created many. Could you please check if the functionality is as expected?
2)
In addition, all stats, as i have seen from for the filters' implementation have been changed. All of them are Strings i suppose. For example, what used to be Long like CampaignID or Date like FromTS or even Boolean attributes, have all been reviewed to Strings at the new API. Also the documentation has remained the same as before the update, stating the previous attributes' types.
Is this intentionally made so or does it need fixing?
Thank you in advance for your reply
Remaining yours
SicoaDev
When i List all objects, i get fine results, but when i try to View one by its ID, i get this message:
"Error '500' - Status returned when an unknow error occurs. Details: Unexpected database error during GET - "
At Update, when i try to update an attribute, i get NullPointerException for what i suppose is inside your API reason , but the attribute is updated alright. This is not convenient as it breaks somewhere just after calling the inside Update function implemented by you and then it stops executing other lines that have t be executed.
At Create, attribute CreatedAt is set as Long and not Date. Is that wanted?
I see in v3 reference in mailJet's site http://dev.mailjet.com/email-api/v3/newsletter-send/ there is the following example:
curl -s -X POST \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/newsletter/:id/send
but I can't find in all your code any example how it should be done with mailjet Java API https://github.com/mailjet/mailjet-apiv3-java?
The same question I have about other parameters that used after newsletter/:id/ such as:
detailcontent, schedule. I suppose that in the case I'll grasp how to work with one of them the handling of others will be the same.
IsEnabled attribute cannot be set value true/false at Create and cannot be Updated. It is not stated as ReadOnly, is this correct?
When i try to Update a Metasender by its ID, i get something like the following message, always maximum expected 1 and always it returns the sum number of the Metasender objects:
"RETURNS: Error '-5' - The MailJet API Client is incorrectly used. Details: Returned object by MailJet API are more than expected. Maximum expected: 1; Returned: 2."
When i try to Update by Email i get the correct results.
Note: Viewing by ID returns a single result and not multiple.
I know that I can generate and use a CustomID, but I would like to also save an ID that I become from MailJet after Send API request:
Request:
curl -X POST --user "xxx:yyy" https://api.mailjet.com/v3/send/message
-F from='Mr Mailjet [email protected]'
-F to=[email protected]
-F subject='Hello World!'
-F text='Greetings from Mailjet.'
Response:
{
"Count" : 1,
"Data" : [
{ "ID" : 199999999999 }
],
"Total" : 1
}
Is it possible to become this ID with Mailjet Java API Wrapper?
Although i can CREATE, VIEW by ID and UPDATE, when i call the LIST function i get this response:
HTTP/1.1 500 Internal Server Error
Error '500' - Status returned when an unknow error occurs. Details: Unexpected error during GET: MJ02 No persister object found for class: "TCSVImportList" -
Greetings
We have been testing your new api implementation, and there seems to be a deep issue. I have attached a screenshot of my simple code and debug screen for more details.
Description:
client = new MailjetClient("mycreds", "mycreds");
request = new MailjetRequest(Contact.resource);
response = client.get(request); ---> This prints out the correct response to the console
What is clearly the response issue, is that it carries out only the response status and not the data JSON part. It may print it on the console, but it does not return it. I cannot access it at all.
I have tried your own testing examples and they do not work as well. They also have some minor mistakes like semicolons and exception declarations missing, just details (in all of http://dev.mailjet.com/guides/?java#the-limit-filter).
Thank you for any help
SicoaDev
When i try to CREATE a Newsletter:
Also
CampaignID attribute is not allowed to be set by Create function and it is not returned when LISTing the newsletters as by Open Issue#19 . Returns: "Error '401' - You have specified an incorrect ApiKey or username/password couple. Details: Internal error: MJ19 Setting a value for property "Campaign" is not allowed - "
There are two imports: "com.mailjet.api.model.v3.newsletter2.Newsletter2.Status", "com.mailjet.api.model.v3.newsletter2.Newsletter2.EditMode" .
What is their purpose?
In the previous API wrapper, one would use the inside attributes like Status, EditMode which would accept specific values etc like this:
Status.DRAFT__0_
How do we use them now?
Could you demonstrate by changing a Newsletter Status to Draft?
@create: "Error '400' - One or more arguments are missing or maybe mispelling. Details: Internal error: Uknown status "" - " . As such, Status is mandatory and is not in the documentation and its values are specific. Can you please state which are the allowed values? I have tested and found Draft for one.
@update: When I tried to update Starred by itself, it responded by updating the value, but I got the message Response = HTTP/1.1 400 Invalid json input: Invalid floating point value at stream position 17 ...ntage":""}|..., float Value="" [Server: nginx, Date: Fri, 25 Sep 2015 09:07:55 GMT, Content-Type: application/json, Content-Length: 170, Connection: keep-alive]
Maybe it helps to find the bug, but i have noted in the past that it took more than one call (maybe 3) to receive an update, although it responded 200ok and after the 3rd time it showed the 304 content not changed Response.
Hello,
I ran across an issue while trying to retrieve a Contactdata object. The exception I'm seeing is: java.lang.IllegalStateException: Expected a long but was BEGIN_OBJECT at line 1 column 56
I dug around the code a little, and it seems as though the Contactdata object (Contactdata.java
) is defining the Data
field this way: private java.util.List<Long> Data
. However, the payload being returned to the wrapper is:
{
"Count": 1,
"Data": [
{
"ContactID": 1,
"Data": [
{
"Name": "foo",
"Value": "Bar"
}
],
"ID": 1
}
],
"Total": 1
}
Clearly the Data
field is not just a list of Long
s.
My original call looks like:
Contactdata cd = this.client.createCall(Contactdata.Get).identifiedBy(ContactdataProperty.ID,
parseLong(ID)).execute();
Any help figuring out what I might be doing wrong would be much appreciated.
I'm using the 1.0.5 distribution.
I have been trying to get this work, but always return 404 error.
I configured base url as http://api.mailjet.com/0.1
Creating newsletter as suggested in the wiki produces the below debug messages
DEBUG [org.apache.http.conn.HttpClientConnectionManager] Connecting to api.mailjet.com/178.32.48.128:80
DEBUG [org.apache.http.impl.execchain.MainClientExec] Executing request POST /0.1/newsletter?style=flat&format=json HTTP/1.1
But as per MailJet API documentation, there is no such api to create a newsletter other then to create a Campaign.
Tried with other API calls as well. API requested doesnt match with the official documentation.
Am I missing anything ?
Thanks,
Madan N
When i try to update IsActive attribute from false to true or the opposite, i get //Error '401' - You have specified an incorrect ApiKey or username/password couple. Details: Not allowed to change IsActive to False - [AND Not allowed to change IsActive to True]
Does that mean that it is an attribute that can be set at Create but not at Update and why?
Hi,
It seems that this wrapper only allow to use the REST API. Can you provide an update to allow also to use the DATA API ? You can have an sample of utilisation at this URL : http://dev.mailjet.com/guides/newsletter-guide/ "Adding an HTML body to a newsletter".
It would be great to upload CSV and HTML files from this wrapper to use them in the REST API.
Thanks,
Julien
Hi,
I can't figure out how to get contact (email) ID and add it to an existing list (with given ID) !
I foudn this : https://app.mailjet.com/docs/api/lists/addcontact ... but I don't see how can I do it in Java :(
Regards :)
We are implementing a plug-in based on the API v3 Java client.
When we try to send a transactional email, we have a NullPointerException.
Here his the output with the VERBOSE_DEBUG :
=== HTTP Request ===
POST https://api.mailjet.com/v3/send
Accept-Charset:UTF-8
Accept:application/json
user-agent:mailjet-apiv3-java/v3.0.0
Content-Type:application/json
=== HTTP Response ===
Receive url: https://api.mailjet.com/v3/send
Status: 400
null:HTTP/1.1 400 Wrong API version
Server:nginx
Connection:keep-alive
Vary:Accept-Encoding
Content-Length:0
Date:Fri, 19 Feb 2016 15:37:33 GMT
Content-Type:text/html
Content:
null
java.lang.NullPointerException
at java.io.StringReader.<init>(StringReader.java:50)
at org.json.JSONTokener.<init>(JSONTokener.java:84)
at org.json.JSONObject.<init>(JSONObject.java:321)
at com.mailjet.client.MailjetClient.post(MailjetClient.java:155)
at amo.plugin.vendors.mailjet.editor.blender.model.WsDataConsumer.setConsumed(WsDataConsumer.java:140)
at amo.editor.blender.model.file.EmptyChainedDataConsumers.setConsumed(EmptyChainedDataConsumers.java:71)
at amo.editor.blender.model.file.DataConsumersAbstract.setConsumed(DataConsumersAbstract.java:15)
at amo.editor.blender.XslFoTool._xslMerge(XslFoTool.java:182)
at amo.editor.blender.XslFoTool.xslMerge(XslFoTool.java:122)
at amo.editor.blender.Main.transform(Main.java:129)
at amo.editor.blender.Main.main(Main.java:101)
Our account seems to use the deprecated v1 API, so we need to migrate it (see mailjet/mailjet-apiv3-nodejs#3).
The MJ Java client should throw a custom error in this case.
Hi, on your documentation you say that multiple filtering can be achieved by using something like this
ResultSet newsletters = client
.createCall(Newsletter.List)
.filterBy(NewsletterFilter.EDITMODE, Newsletter.EditMode.HTML)
.filterBy(NewsletterFilter.ISDELETED, false)
.execute();
My question is : Does this mean that the results of the first filter are afterwards filtered anew by he next filter, or that there are two independent filters that are applied to the same data?
If the first case is true, then how do I implement two independent filters at the same data in one method call?
At MessageStatistics, MessageStatus Filter (Only retrieve messages with status equal to specified value. [ Type TMessageStatus ] ) is type Long but at MessageSentStatistics, MessageStatus Filter (Only retrieve messages with Status equal to specified value. [ Type AnsiString ] ) is type String.
Is this as it is supposed to be? What is their difference and what values are meaning what? Status in Message is String type with specific values. How about the Long one?
Hi,
I am starting to use your library to send emails. But when I am building the client, I am encountering this exception:
java.lang.reflect.InvocationTargetException com.mailjet.api.client.config.MailJetClientConfigurationException: java.lang.reflect.InvocationTargetException
I am using the code in example:
MailJetClientConfiguration config = new MailJetClientConfiguration()
.setBaseUrl("https://api.mailjet.com/v3/")
.setDefaultApiKey(Email.apiKey)
.setDefaultSecretKey(Email.secretKey);
MailJetApiClient client = config.buildClient();
Any idea? Thanks!
I have encountered the following non-existing Functions that are however still there on the API Reference manuals. Please can you confirm that they do are nonexistent, and maybe if and which might follow in the future:
ApiKeyTotals: VIEW
CampaignStatistics: VIEW
Preferences: CREATE, UPDATE, DELETE
AggregateGraphStats: VIEW
ContactStatistics: VIEW
GeoStatistics: VIEW
GraphStatistics: VIEW
ListRecipientStatistics: VIEW
MessageHistory: VIEW
MessageSentStatistics: VIEW
MessageStatistics: VIEW
OpenStatistics: VIEW
SenderStatistics: VIEW
UserAgentStatistics: VIEW
Hello
When i try to update a Contact, i get this message:
{"Status":401,"ErrorInfo":"","ErrorMessage":"Internal error: MJ19 Setting a value for property "UnsubscribedAt" is not allowed","StatusCode":401}
However i do not try to update "UnsubscribedAt", only "Name".
My partial code derived straight from your example
https://github.com/mailjet/mailjet-apiv3-java#get-and-update-a-sender ->
MailjetRequest update = null;
MailjetRequest getContact = new MailjetRequest(Contact.resource).filter(Contact.ID, id);
MailjetResponse contacts;
contacts = cl.get(getContact);
JSONObject contact = contacts.getData().getJSONObject(0);
update = new MailjetRequest(Contact.resource, contact.getLong("ID"))
.setBody(contact.put(Contact.NAME, Name));
/* FROM DEBUG THE VALUES AT THIS POINT ARE:
update:
{"Action":"","Filters":"{}","Action ID":0,"Resource":"contact","ID":1,"Body":"{\"LastActivityAt\":\"2015-12-02T10:08:27Z\",\"UnsubscribedBy\":\"\",\"IsSpamComplaining\":false,\"DeliveredCount\":1,\"Email\":\"[email protected]\",\"IsOptInPending\":false,\"LastUpdateAt\":\"2015-07-27T10:38:10Z\",\"CreatedAt\":\"2015-06-29T11:12:47Z\",\"ID\":1,\"UnsubscribedAt\":\"\",\"Name\":\"NewNameUPDATED\"}"}
contacts:
{"Status":200,"Total":1,"Data":[{"LastActivityAt":"2015-12-02T10:08:27Z","UnsubscribedBy":"","IsSpamComplaining":false,"DeliveredCount":1,"Email":"[email protected]","IsOptInPending":false,"LastUpdateAt":"2015-07-27T10:38:10Z","CreatedAt":"2015-06-29T11:12:47Z","ID":1,"UnsubscribedAt":"","Name":"NewNameUPDATED"}],"Count":1}
contact:
{"LastActivityAt":"2015-12-02T10:08:27Z","UnsubscribedBy":"","IsSpamComplaining":false,"DeliveredCount":1,"Email":"[email protected]","IsOptInPending":false,"LastUpdateAt":"2015-07-27T10:38:10Z","CreatedAt":"2015-06-29T11:12:47Z","ID":1,"UnsubscribedAt":"","Name":"NewNameUPDATED"}
THEN CALLING PUT(UPDATE) IT BREAKS AS IT TRIES TO SET A PROPERTY VALUE THROUGH THE JSON, EVEN IF EMPTY IN THE CONTACT, WHICH IS NOT ALLOWED
*/
System.out.println(cl.put(update));
Thank you for any insight into this issue. Maybe i have done something wrong?
Yours sincerely
SicoaDev
I encountered the almost same issue in both of my implementations.
While i wrote and called both MetadataProperty and MessageInformationProperty,
the compiler of Eclipse broke, stating in the beginning at the declaration of the package the class belongs, these messages, accordingly to each class:
MetadataClass: The type com.mailjet.api.model.v3.customtypes.Property cannot be resolved. It is indirectly referenced from required .class files
MessageInformationClass: The type com.mailjet.api.model.v3.customtypes.SpamAssassinRuleList cannot be resolved. It is indirectly referenced from required .class
files
Thank you for your help in advance
OD
Hello once more and thank you in advance for your insight.
I have been involved with testing the filters right now and i got an issue, which i believe we have discussed a bit before but i have lost it. Maybe i am doing something wrong..
I am trying by the wrapper and by curl and although i have 4 campaigns at SENT ,
i get as result all campaigns that i have constructed
curl:
https://api.mailjet.com/v3/REST/campaignstatistics?Sent=true
java
request = new MailjetRequest(Campaignstatistics.resource);
request.filter(Campaignstatistics.SENT, sentfilter); //sentfilter: String set as "true". Boolean not allowed
response = cl.get(request);
the request:
{"Filters":"{Sent=true}","Body":"{}","Resource":"campaignstatistics","ID":0,"Action ID":0}
Response: All Campaignstatistics
ListRecipient shows ContactID as mandatory and ReadOnly. That is a question by itself.
At CREATE, when I try to create a new listRecipient without any ContactID, I get a response "Error '400' - One or more arguments are missing or maybe mispelling. Details: Object properties invalid - MJ08 Property Contact is invalid: MJ03 A non-empty value is required"
By using the functions i get Internal Error when trying to Update a ContactID at a ListRecipient whereas i can Create without problems if i have a ContactID.
Does this mean that Mandatory goes to Create and ReadOny to Update?
Hello, i would like to understand how managecontactslists works and how that applies to the rest of submethods in API, used for the java wrapper.
Thank you
sicoaDev
contact/:id/managecontactslists
Method: Create
Subscribe the contact to the given contact lists
curl -s -X POST
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE"
https://api.mailjet.com/v3/REST/contact/:id/managecontactslists
-H 'Content-Type: application/json'
-d '{"ContactsLists": ...}'
ContactsLists Mandatory [ Type TContactsListActionList
QUESTION: what is the input here? The lists' ids?
QUESTION2:
In the library implementation what should i do?
The following does not work and it is very important to me right now:
request
{"Action":"","Filters":"{}","Action ID":0,"Resource":"contact","ID":1.......33,"Body":"{"ContactsLists":[{"Action":"addforce","ListID":"1"}]}"}
response:
{"Status":405,"ErrorInfo":"","ErrorMessage":"Method not allowed","StatusCode":405}
request = new MailjetRequest(Contact.resource, contactID)
.property(ContactManagecontactslists.CONTACTSLISTS, new JSONArray()
.put(new JSONObject()
.put("ListID", listID)
.put("Action", action)));
Following the guide, I am getting a java.lang.reflect.InvocationTargetException
when I try to build the client.
MailJetClientConfiguration config = new MailJetClientConfiguration()
.setBaseUrl("https://api.mailjet.com/api/v3/REST")
.setDefaultApiKey("api_key")
.setDefaultSecretKey("api_secret");
MailJetApiClient client = config.buildClient();
ResultSet<Campaign> campaigns = client
.createCall(Campaign.List)
.execute();
Greetings again
There are some issues regarding campaigns and newsletters. If there ain't any, maybe its my misunderstanding of their practical use.
I had sent some time ago 2 newsletters for testing purposes and none appeared as they should have, when i called Campaign.LIST through your API library.
Today i sent 2 from your platform and as a result, Campaign.LIST shows 2 and Newsletter.LIST returns 1. The one Newsletter is the same as the one Campaign returned.
Resuming, now i have 2 Drafts and 4 Sent at the Campaigns section, the Campaigns.LIST shows 2 and no draft from those, and Newsletter only 1 (instead of how many as there seems to a dinstiction between newsletters and campaigns?) which is the same as 1 of the 2 Campaigns
Thank you
OD
In messagehistory class, no GET seems to be working.
Firstly, when i try to call your url
https://api.mailjet.com/v3/REST/messagehistory
with my credentials i get
{ "ErrorIdentifier" : "24C9B990-C8C6-4E19-976E-E4B62A512076", "ErrorInfo" : "", "ErrorMessage" : "Unexpected database error during GET", "StatusCode" : 500 }
Secondly, .List is an option, even though it does not work by my implementation, but there is no way to use the View function, as there is no .Get nor an ID to search by.
# access the messagehistory resource identified by $ID
curl -s -X GET \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/messagehistory/$ID
When i Create a new CSVImport, i set -following your instructions- Status as a String by value "Upload". I even tried with "upload" and without any STATUS value at all.
Then, using the ID i return, i VIEW the specific CSVImport instance and it always has Status as "Aborted".
Because of that reason, when i try to UPDATE, i always get
<<HTTP/1.1 500 Internal Server Error
Error '400' - One or more arguments are missing or maybe mispelling. Details: Invalid value for Status: "Aborted". Status can only be set to Upload - >>
even if by default i do not set any value to Status
Hi,
Is there any way to use the Send API using this library?
Thanks,
Greetings once more
and straight to the point :)
ListRecipient has a number of issues for me:
1)
When listed, the contents have an attribute, not shown in the documentation: “ListName”. Is this supposed to be available at update and create?
Cannot create a ListRecipient:
When trying to Create a new ListRecipient setting the mandatory ContactListID
the call is below and i provide values for all but UnsubscribedAt
request = new MailjetRequest(Listrecipient.resource)
.property(Listrecipient.ACTIVE, IsActive)
.property(Listrecipient.ISUNSUBSCRIBED, IsUnsubscribed)
.property(Listrecipient.UNSUBSCRIBEDAT, UnsubscribedAt)
.property(Listrecipient.CONTACTSLIST, ContactListID);
In the end of the call the request is:
{"Filters":"{}","Body":"{\"ContactsList\":1,\"Active\":true,\"IsUnsubscribed\":false,\"UnsubscribedAt\":\"\"}","Resource":"listrecipient","ID":0,"Action ID":0}
And finally, the response:
{"ErrorInfo":"","StatusCode":400,"Status":400,"ErrorMessage":"Invalid json input: object \"\"->\"TListRecipient\" has no property \"ContactsList\""}
Cannot update a ListRecipient
When i tried to update IsActive from false to true, and only that, i got:
WITH PUT (update = new MailjetRequest(Listrecipient.resource, listRecipient.getLong("ID")).setBody(listRecipient.put(Listrecipient.ISACTIVE, isActive));
)
->
{"ErrorInfo":"","StatusCode":400,"Status":400,"ErrorMessage":"Invalid json input: object \"\"->\"TListRecipient\" has no property \"ListName\""}
Once more at client.put(update)
update is correct but the response is the above
update:
{"Filters":"{}","Body":"{\"IsUnsubscribed\":false,\"UnsubscribedAt\":\"\",\"IsActive\":true,\"ID\":34,\"ContactID\":2,\"ListID\":1,\"ListName\”:\”test\”}”,”Resource":"listrecipient","Action":"","ID":34,"Action ID":0}
WITHOUT PUT (update = new MailjetRequest(Listrecipient.resource, listRecipient.getLong("ID”).property(Listrecipient.ISACTIVE, isActive);)
->
update:
{"Filters":"{}","Body":"{"IsActive":true}","Resource":"listrecipient","Action":"","ID":34,"Action ID":0}
and i get the following exception when cl.put(update) is called
exception [org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]] with root cause
org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
Delete seems to be broken as well, if i get this right.
I call:
request = new MailjetRequest(Listrecipient.resource, id);
response=cl.delete(request);
This returns the Listrecipient and does not delete it.
sorry i just checked new api structure. i am sorry
Hello Folks,
I'm trying basic email sending. When I use a JUnit test case things goes all right, but when I try the same code in a WebApp (running on Tomcat) email is not sent. No MailjetException is thrown and when I inspect my MailjetResponse object I only get Response Status 400.
`
MailjetClient client = new MailjetClient("_", "_");
MailjetRequest email;
JSONArray recipients;
MailjetResponse response;
recipients = new JSONArray()
.put(new JSONObject().put(Contact.EMAIL, "[email protected]"));
email = new MailjetRequest(Email.resource)
.property(Email.FROMNAME, "Teste")
.property(Email.FROMEMAIL, "[email protected]")
.property(Email.SUBJECT, "Testando")
.property(Email.HTMLPART, "<html> <body> <h1>Teste</h1> <p>Lorem ipsum..</p></body> </html>")
.property(Email.RECIPIENTS, recipients)
.property(Email.MJCUSTOMID, "JAVA-Email");
try {
response = client.post(email);
} catch (MailjetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}`
Whould you please give me some ideas about how to fix it? Is some parameter wrong?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.