Re: Import leads with Rest API

Anonymous
Not applicable

Import leads with Rest API

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!
Tags (1)
4 REPLIES 4
Anonymous
Not applicable

Re: Import leads with Rest API

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? 
Anonymous
Not applicable

Re: Import leads with Rest API

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? 
Anonymous
Not applicable

Re: Import leads with Rest API

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).
 
Anonymous
Not applicable

Re: Import leads with Rest API

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