<?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: Rest/API for File upload in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/799206#M64366</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/665"&gt;@IsaacTakushi&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;I have been trying to send a replace file content request from my server (Node JS).&lt;BR /&gt;I want to update the content of a json file, but I am getting a 400 error:&lt;BR /&gt;&lt;BR /&gt;Here's my code:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;FormData&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;require&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'form-data'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;hubspotHeaders&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;Headers&lt;/SPAN&gt;&lt;SPAN&gt;();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; // Tried the different headers&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; // hubspotHeaders.set('content-type', 'multipart/form-data');&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// hubspotHeaders.set(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// &amp;nbsp;'content-type',&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// &amp;nbsp;'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// );&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; hubspotHeaders&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;set&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'content-type'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'application/x-www-form-urlencoded'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; hubspotHeaders&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;append&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'authorization'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;`Bearer &lt;/SPAN&gt;&lt;SPAN&gt;AccessKey&lt;/SPAN&gt;&lt;SPAN&gt;`&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;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gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; body&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;formData&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;};&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;response&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;await&lt;/SPAN&gt; &lt;SPAN&gt;fetch&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;`&lt;/SPAN&gt;&lt;SPAN&gt;${&lt;/SPAN&gt;&lt;SPAN&gt;_hubspotFileApiBaseUrl&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;${&lt;/SPAN&gt;&lt;SPAN&gt;fileId&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;`&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;requestOption&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;Was hoping to get your help if possible,&lt;BR /&gt;Thank you&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 25 May 2023 20:13:21 GMT</pubDate>
    <dc:creator>SRitchot</dc:creator>
    <dc:date>2023-05-25T20:13:21Z</dc:date>
    <item>
      <title>Rest/API for File upload</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/280715#M25797</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;In the Hubspot documentation there is an example for File upload using &lt;A href="https://developers.hubspot.com/docs/methods/files/post_files" target="_self"&gt;Python code&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Is there a Rest API example for file upload?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yoram&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 17:32:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/280715#M25797</guid>
      <dc:creator>yorambaron</dc:creator>
      <dc:date>2019-07-15T17:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: Rest/API for File upload</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/280949#M25815</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/98108"&gt;@yorambaron&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The CMS Files API, which&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/methods/files/post_files" target="_self"&gt;this endpoint&lt;/A&gt; is part of, is a REST API. Are you referring to a JavaScript example?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, something like this just worked for me:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;var data = new FormData();
data.append("files", "/Users/my/file/location.jpg");
data.append("file_names", "My File Name");

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.open("POST", "https://api.hubapi.com/filemanager/api/v2/files?hapikey=my_key");
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

xhr.send(data);&lt;/PRE&gt;
&lt;P&gt;Please let me know if I've misunderstood your request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 19:06:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/280949#M25815</guid>
      <dc:creator>IsaacTakushi</dc:creator>
      <dc:date>2019-07-16T19:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Rest/API for File upload</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281193#M25846</link>
      <description>&lt;P&gt;Hello Issac,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply, I tried to write a simillar code in Java, I&amp;nbsp; received an error:&lt;/P&gt;&lt;P&gt;"415 Unsupported Media Type HTTP/1.1", I did set the value:&lt;/P&gt;&lt;P&gt;Content-type: "Application-Json" in the header.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is the Java code:&lt;/P&gt;&lt;P&gt;HttpPost post = new HttpPost("&lt;A href="http://api.hubapi.com/filemanager/api/v2/files?hapikey=&amp;lt;value" target="_blank"&gt;http://api.hubapi.com/filemanager/api/v2/files?hapikey=&amp;lt;value&lt;/A&gt;&amp;gt;");&lt;BR /&gt;JSONObject params = new JSONObject();&lt;BR /&gt;params.put("files", "&amp;lt;value&amp;gt;");&lt;BR /&gt;StringEntity stringEntity = new StringEntity(params.toString());&lt;BR /&gt;post.addHeader("Content-Type","application/json");&lt;BR /&gt;post.setEntity(new StringEntity(params.toString(), StandardCharsets.UTF_8));&lt;BR /&gt;HttpClient httpclient = HttpClients.createDefault();&lt;BR /&gt;HttpResponse response = httpclient.execute(post);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yoram&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 17:43:51 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281193#M25846</guid>
      <dc:creator>yorambaron</dc:creator>
      <dc:date>2019-07-17T17:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Rest/API for File upload</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281194#M25847</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/98108"&gt;@yorambaron&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy to clarify.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Per &lt;A href="https://developers.hubspot.com/docs/methods/files/post_files" target="_self"&gt;the article&lt;/A&gt;, you will want to use &lt;CODE&gt;Content-Type: "multipart/form-data"&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 17:52:53 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281194#M25847</guid>
      <dc:creator>IsaacTakushi</dc:creator>
      <dc:date>2019-07-17T17:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rest/API for File upload</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281201#M25851</link>
      <description>&lt;P&gt;Hello Issac,&lt;/P&gt;&lt;P&gt;Thanks again for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed the Content-type to "multipart/form-data".&lt;/P&gt;&lt;P&gt;I now receive the following error: "500 Internal Server Error HTTP/1.1".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yoram&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 18:17:37 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281201#M25851</guid>
      <dc:creator>yorambaron</dc:creator>
      <dc:date>2019-07-17T18:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Rest/API for File upload</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281499#M25888</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/98108"&gt;@yorambaron&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not proficient enough with Java to identify the issue in your code, but I'm seeing examples out there with both of these headers:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;"content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
"Content-Type", "application/x-www-form-urlencoded"&lt;/PRE&gt;
&lt;P&gt;Could you try with these?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 21:25:09 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281499#M25888</guid>
      <dc:creator>IsaacTakushi</dc:creator>
      <dc:date>2019-07-18T21:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Rest/API for File upload</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281713#M25910</link>
      <description>&lt;P&gt;Hello Issac,&lt;/P&gt;&lt;P&gt;What you suggested&amp;nbsp; didn't work for me.&lt;/P&gt;&lt;P&gt;My understanding is that your API requires to load the entire file content into memory.&lt;/P&gt;&lt;P&gt;So far I haven't found a yet that it will work for me on a Java client code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yoeam&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 19:04:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281713#M25910</guid>
      <dc:creator>yorambaron</dc:creator>
      <dc:date>2019-07-19T19:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Rest/API for File upload</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281741#M25915</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/98108"&gt;@yorambaron&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I am not familiar with Java, I may not be of much further help, but what about trying the following approaches:&lt;BR /&gt;&lt;BR /&gt;With &lt;A href="https://square.github.io/okhttp/" target="_self"&gt;OkHttp&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
RequestBody body = RequestBody.create(mediaType, "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"files\"; filename=\myphoto.png\"\r\nContent-Type: image/png\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--");
Request request = new Request.Builder()
  .url("https://api.hubapi.com/filemanager/api/v2/files?hapikey=my_key")
  .post(body)
  .addHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW")
  .addHeader("Content-Type", "multipart/form-data")
  .build();

Response response = client.newCall(request).execute();&lt;/PRE&gt;
&lt;P&gt;With &lt;A href="http://kong.github.io/unirest-java/" target="_self"&gt;Unirest&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;HttpResponse&amp;lt;String&amp;gt; response = Unirest.post("https://api.hubapi.com/filemanager/api/v2/files?hapikey=my_key")
  .header("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW")
  .header("Content-Type", "multipart/form-data")
  .body("------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"files\"; filename=\"myfile.png\"\r\nContent-Type: image/png\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--")
  .asString();&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 21:31:29 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/281741#M25915</guid>
      <dc:creator>IsaacTakushi</dc:creator>
      <dc:date>2019-07-19T21:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rest/API for File upload</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/289199#M26811</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 08:53:59 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/289199#M26811</guid>
      <dc:creator>yorambaron</dc:creator>
      <dc:date>2019-09-02T08:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Rest/API for File upload</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/799206#M64366</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/665"&gt;@IsaacTakushi&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;I have been trying to send a replace file content request from my server (Node JS).&lt;BR /&gt;I want to update the content of a json file, but I am getting a 400 error:&lt;BR /&gt;&lt;BR /&gt;Here's my code:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;FormData&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;require&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'form-data'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;hubspotHeaders&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;Headers&lt;/SPAN&gt;&lt;SPAN&gt;();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; // Tried the different headers&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; // hubspotHeaders.set('content-type', 'multipart/form-data');&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// hubspotHeaders.set(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// &amp;nbsp;'content-type',&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// &amp;nbsp;'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// );&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; hubspotHeaders&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;set&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'content-type'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'application/x-www-form-urlencoded'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; hubspotHeaders&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;append&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'authorization'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;`Bearer &lt;/SPAN&gt;&lt;SPAN&gt;AccessKey&lt;/SPAN&gt;&lt;SPAN&gt;`&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;formData&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;FormData&lt;/SPAN&gt;&lt;SPAN&gt;();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;formData&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;append&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'file'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;fs&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;createReadStream&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPA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t;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;${&lt;/SPAN&gt;&lt;SPAN&gt;fileId&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;`&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;requestOption&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;Was hoping to get your help if possible,&lt;BR /&gt;Thank you&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 25 May 2023 20:13:21 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Rest-API-for-File-upload/m-p/799206#M64366</guid>
      <dc:creator>SRitchot</dc:creator>
      <dc:date>2023-05-25T20:13:21Z</dc:date>
    </item>
  </channel>
</rss>

