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

Csvimport.DATA does not exist #183

Closed
yolefebvre opened this issue Feb 20, 2023 · 2 comments
Closed

Csvimport.DATA does not exist #183

yolefebvre opened this issue Feb 20, 2023 · 2 comments

Comments

@yolefebvre
Copy link

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
CSVImport

@vitalii-chornobryvyi-swi
Copy link
Collaborator

@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?

@vitalii-chornobryvyi-swi
Copy link
Collaborator

the issue has been fixed, commented on and is closed due to the lack of an answer

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