Import leads with Rest API | Community
Skip to main content
August 6, 2014
Question

Import leads with Rest API

  • August 6, 2014
  • 4 replies
  • 1568 views
Does anyone have a working java example to import leads through the Rest API? I always get the following error

[{"code":"610","message":"Requested resource not found"}]

with the code

CloseableHttpClient httpclient = HttpClients.createDefault();
 
String targetUrl = REST_ENDPOINT + "/bulk/v1/leads.json?access_token="+token;
 
try
{
            HttpPost httpPost = new HttpPost(targetUrl);
        
            FileBody bin = new FileBody(new File("/myfiles/test_data.csv"));
 
            HttpEntity reqEntity = MultipartEntityBuilder.create()
               .addTextBody("listId", "1234")
               .addTextBody("format", "csv")
                .addPart("file", bin)
                .build();
 
            httpPost.setEntity(reqEntity);        
        
            CloseableHttpResponse response2 = httpclient.execute(httpPost);


Thank you!
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

August 7, 2014
Currently we do not have any code samples in Java for the REST API. It is on my todo list. 

Could you please post your request header & body? 
September 16, 2014
requested resource not found usually refers to you not hitting the right endpoint.  It looks like you are doing import list call, maybe your REST_ENDPOINT is not right? 
April 1, 2015
Hey guys,

I'm having the same problem with the Import Leads REST API. I'm using cURL (as per documentation) with the endpoint copied directly from MKTO. Any advice would be helpful (I'm wondering if the documentation is out of date).
 
July 14, 2015

Hi all

I tried today and this API is still alive.

I feel "file" parameter as multi part is very sensitive.

If your app can not work fine, compare multi part section in doc sample carefully.

Import Lead » Marketo Developers