You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@yolefebvre, thanks for raising this issue!
Sorry for the late reply.
The mentioned functionality was updated in the new release 5.2.4. To perform uploading CSV file through the DATA API you can do this:
public class MyClass {
/**
* A wrapper for the CSV upload
*/
public static void main(String[] args) throws MailjetException {
ClientOptions clientOptions;
MailjetClient client;
MailjetRequest request;
MailjetResponse response;
clientOptions = ClientOptions
.builder()
.apiKey(System.getenv("MJ_APIKEY_PUBLIC"))
.apiSecretKey(System.getenv("MJ_APIKEY_PRIVATE"))
.build();
client = new MailjetClient(clientOptions);
request = new MailjetRequest(Contactslist.csvDataResource, CONTACT_LIST_ID)
.attachFile(new File("/test.csv"));
response = client.post(request);
System.out.println(response.getStatus());
System.out.println(response.getData());
}
}
Documentation for that will be also updated after the 26th of September.
Please let us know If everything works for you and If issue can be closed?
I want to use upload and I copy the code found in the doc for java.
But, there is no DATA in the Csvimport class.
Csvimport.DATA
https://dev.mailjet.com/email/guides/contact-management/#manage-contacts-via-csv-upload
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.errors.MailjetSocketTimeoutException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Csvimport;
import org.json.JSONArray;
import org.json.JSONObject;
public class MyClass {
/**
* Modify : A wrapper for the CSV importer
*/
public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
MailjetClient client;
MailjetRequest request;
MailjetResponse response;
client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
request = new MailjetRequest(Csvimport.resource, ID)
.property(Csvimport.DATA, MYFILE);
response = client.put(request);
System.out.println(response.getStatus());
System.out.println(response.getData());
}
}
https://github.com/mailjet/mailjet-apiv3-java/issues/62
The text was updated successfully, but these errors were encountered: