<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Components for http post request in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Components-for-http-post-request/m-p/2371422#M134368</link>
    <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't think that you can pass a file in a post method with a talend component. Maybe in a premium version ...&lt;BR /&gt;&lt;BR /&gt;But check your private message. We can talk about this.&lt;BR /&gt;&lt;BR /&gt;Good luck,&lt;/P&gt;&lt;P&gt;SGV&lt;/P&gt;</description>
    <pubDate>Thu, 21 Dec 2017 13:53:18 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-12-21T13:53:18Z</dc:date>
    <item>
      <title>Components for http post request</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Components-for-http-post-request/m-p/2371421#M134367</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello, &lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN&gt;I want to make a&amp;nbsp;http post request&amp;nbsp;to sending a file in parameter and return a file. The java code below works. With which component and what parameters can we do the equivalent? (I tested tfileFetch, tHttpPost etc ... but maybe with parameter errors)&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;import java.io.BufferedInputStream;&lt;BR /&gt;import java.io.BufferedOutputStream;&lt;BR /&gt;import java.io.File;&lt;BR /&gt;import java.io.FileInputStream;&lt;BR /&gt;import java.io.FileOutputStream;&lt;BR /&gt;import java.io.IOException;&lt;/P&gt; 
&lt;P&gt;import org.apache.http.HttpEntity;&lt;BR /&gt;import org.apache.http.HttpResponse;&lt;BR /&gt;import org.apache.http.client.ClientProtocolException;&lt;BR /&gt;import org.apache.http.client.methods.HttpPost;&lt;BR /&gt;import org.apache.http.entity.mime.MultipartEntityBuilder;&lt;BR /&gt;import org.apache.http.entity.mime.content.InputStreamBody;&lt;BR /&gt;import org.apache.http.impl.client.CloseableHttpClient;&lt;BR /&gt;import org.apache.http.impl.client.HttpClients;&lt;/P&gt; 
&lt;P&gt;&lt;BR /&gt;public class Adresses {&lt;BR /&gt;&lt;BR /&gt;public static void GeocodeAdresses(String cheminFichierSource, String cheminFichierCible) {&lt;BR /&gt;&lt;BR /&gt;// Préparation du fichier à uploader&lt;BR /&gt;File fichierSource = new File(cheminFichierSource.replace("/", "\\"));&lt;BR /&gt;FileInputStream fichierUpload = null;&lt;BR /&gt;try {&lt;BR /&gt;fichierUpload = new FileInputStream(fichierSource);&lt;BR /&gt;CloseableHttpClient httpclient = HttpClients.createDefault();&lt;/P&gt; 
&lt;P&gt;// URL API&lt;BR /&gt;HttpPost httppost = new HttpPost("&lt;A href="https://api-adresse.data.gouv.fr/search/csv/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://api-adresse.data.gouv.fr/search/csv/&lt;/A&gt;");&lt;BR /&gt;MultipartEntityBuilder entity = MultipartEntityBuilder.create();&lt;BR /&gt;&lt;BR /&gt;// Paramètres&lt;BR /&gt;entity.addPart("data", new InputStreamBody(fichierUpload, fichierSource.getName()));&lt;BR /&gt;httppost.setEntity(entity.build());&lt;BR /&gt;&lt;BR /&gt;// Exécution de la requête&lt;BR /&gt;HttpResponse reponse = httpclient.execute(httppost);&lt;BR /&gt;&lt;BR /&gt;// Code retour&lt;BR /&gt;int statusCode = reponse.getStatusLine().getStatusCode();&lt;BR /&gt;System.out.println("Code retour : " + statusCode);&lt;BR /&gt;&lt;BR /&gt;// Téléchargement du fichier&lt;BR /&gt;HttpEntity reponseEntity = reponse.getEntity();&lt;BR /&gt;BufferedInputStream bis = new BufferedInputStream(reponseEntity.getContent());&lt;BR /&gt;BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(cheminFichierCible.replace("/","\\"))));&lt;BR /&gt;int inByte;&lt;BR /&gt;while((inByte = bis.read()) != -1) bos.write(inByte);&lt;BR /&gt;bis.close();&lt;BR /&gt;bos.close();&lt;BR /&gt;&lt;BR /&gt;} catch (ClientProtocolException e) {&lt;BR /&gt;System.err.println("Connexion impossible");&lt;BR /&gt;e.printStackTrace();&lt;BR /&gt;} catch (IOException e) {&lt;BR /&gt;System.err.println("Lecture du fichier impossible");&lt;BR /&gt;e.printStackTrace();&lt;BR /&gt;} finally {&lt;BR /&gt;try {&lt;BR /&gt;if (fichierUpload != null) fichierUpload.close();&lt;BR /&gt;} catch (IOException e) {}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;},&lt;BR /&gt;&lt;BR /&gt;Thanks for your help,&lt;BR /&gt;Pauline&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 13:23:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Components-for-http-post-request/m-p/2371421#M134367</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-12-20T13:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Components for http post request</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Components-for-http-post-request/m-p/2371422#M134368</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't think that you can pass a file in a post method with a talend component. Maybe in a premium version ...&lt;BR /&gt;&lt;BR /&gt;But check your private message. We can talk about this.&lt;BR /&gt;&lt;BR /&gt;Good luck,&lt;/P&gt;&lt;P&gt;SGV&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2017 13:53:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Components-for-http-post-request/m-p/2371422#M134368</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-12-21T13:53:18Z</dc:date>
    </item>
  </channel>
</rss>

