4 Replies Latest reply on Jul 14, 2015 3:39 AM by Takehiro Masaki

    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!