<?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: Upload a file using api In C# in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390893#M38564</link>
    <description>&lt;P&gt;Why are you using the old api ?&lt;/P&gt;</description>
    <pubDate>Thu, 03 Dec 2020 10:17:35 GMT</pubDate>
    <dc:creator>quentin_lamamy</dc:creator>
    <dc:date>2020-12-03T10:17:35Z</dc:date>
    <item>
      <title>Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/389892#M38448</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to use this endpoint to upload file to hub spot in c#.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;http://api.hubapi.com/filemanager/api/v3/files/upload?hapikey=dem&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Documnet URL:&amp;nbsp;&lt;A href="https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file" target="_blank" rel="noopener"&gt;https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not able to make request model&amp;nbsp; for that any help will be appriciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 21:00:30 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/389892#M38448</guid>
      <dc:creator>Abhimanyu</dc:creator>
      <dc:date>2020-11-30T21:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390024#M38477</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/150567"&gt;@Abhimanyu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know there is a &lt;A href="https://github.com/hubspot-net/HubSpot.NET" target="_blank" rel="noopener"&gt;wrapper&lt;/A&gt; that allows you to upload a file to an engagement.&amp;nbsp; Maybe looking at&amp;nbsp; that you can figure out how to compose this.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/148828"&gt;@quentin_lamamy&lt;/a&gt; , I know you usually work with the CRM, but have you tried uploading to the file manager?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 18:33:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390024#M38477</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2020-11-30T18:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390093#M38482</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/13982"&gt;@dennisedson&lt;/a&gt;Thanks for the ping&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/150567"&gt;@Abhimanyu&lt;/a&gt;What is your actual code and what is the answer of the hubspot api ?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 17:41:37 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390093#M38482</guid>
      <dc:creator>quentin_lamamy</dc:creator>
      <dc:date>2021-01-21T17:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390184#M38489</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/148828"&gt;@quentin_lamamy&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Here's my code&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;using (var request = new HttpRequestMessage(new HttpMethod("POST"), "&lt;A href="http://api.hubapi.com/filemanager/api/v3/files/upload?hapikey=demo" target="_blank"&gt;http://api.hubapi.com/filemanager/api/v3/files/upload?hapikey=demo&lt;/A&gt;"))&lt;BR /&gt;{&lt;BR /&gt;var multipartContent = new MultipartFormDataContent();&lt;BR /&gt;var options = new&lt;BR /&gt;{&lt;BR /&gt;options = new { access = "PUBLIC_INDEXABLE" }&lt;BR /&gt;&lt;BR /&gt;};&lt;BR /&gt;var properties = JsonConvert.SerializeObject(options);&lt;BR /&gt;&lt;BR /&gt;var file1 = new ByteArrayContent(File.ReadAllBytes("C:\\Users\\abhimanyu.kumar\\Downloads\\1.png"));&lt;BR /&gt;file1.Headers.Add("Content-Type", "multipart/form-data");&lt;BR /&gt;multipartContent.Add(file1, "+", Path.GetFileName("1.png"));&lt;BR /&gt;multipartContent.Add(new StringContent(properties));&lt;BR /&gt;multipartContent.Add(new StringContent("/Abhimanyu_Test"), "folderPath");&lt;BR /&gt;request.Content = multipartContent;&lt;/P&gt;&lt;P&gt;var response = await httpClient.SendAsync(request);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And Response is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent, Headers:&lt;BR /&gt;{&lt;BR /&gt;Date: Tue, 01 Dec 2020 10:27:29 GMT&lt;BR /&gt;Connection: keep-alive&lt;BR /&gt;Set-Cookie: __cfduid=d439fa73df3a0b3f3f5d5b3b862563a331606818449; expires=Thu, 31-Dec-20 10:27:29 GMT; path=/; domain=.hubapi.com; HttpOnly; SameSite=Lax&lt;BR /&gt;X-Trace: 2B3B778C5B16B2FEEB75D4A27E9BE1A3C8C64CF3A1000000000000000000&lt;BR /&gt;X-HubSpot-RateLimit-Daily: 500000&lt;BR /&gt;X-HubSpot-RateLimit-Daily-Remaining: 499907&lt;BR /&gt;X-HubSpot-RateLimit-Interval-Milliseconds: 10000&lt;BR /&gt;X-HubSpot-RateLimit-Remaining: 99&lt;BR /&gt;X-HubSpot-RateLimit-Max: 100&lt;BR /&gt;X-HubSpot-RateLimit-Secondly: 10&lt;BR /&gt;X-HubSpot-RateLimit-Secondly-Remaining: 9&lt;BR /&gt;Access-Control-Allow-Credentials: false&lt;BR /&gt;CF-Cache-Status: DYNAMIC&lt;BR /&gt;cf-request-id: 06bf70e0e90000ab04850e7000000001&lt;BR /&gt;CF-RAY: 5fac1dae3824ab04-MAA&lt;BR /&gt;Cache-Control: no-store, must-revalidate, no-cache&lt;BR /&gt;Server: cloudflare&lt;BR /&gt;Content-Type: text/html; charset=iso-8859-1&lt;BR /&gt;Content-Length: 267&lt;BR /&gt;}}&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2020 10:32:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390184#M38489</guid>
      <dc:creator>Abhimanyu</dc:creator>
      <dc:date>2020-12-01T10:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390200#M38493</link>
      <description>&lt;P&gt;Thanks for the answer, i suggest you to use the new endpoint documented&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/api/cms/files" target="_blank" rel="noopener"&gt;here&lt;/A&gt; and use this php &lt;A href="https://community.hubspot.com/t5/APIs-Integrations/CMS-Files-API-on-PHP-Upload-a-new-file-Error-400-Bad-Request/m-p/381560" target="_blank" rel="noopener"&gt;working code&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 17:41:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390200#M38493</guid>
      <dc:creator>quentin_lamamy</dc:creator>
      <dc:date>2021-01-21T17:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390521#M38525</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/148828"&gt;@quentin_lamamy&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/13982"&gt;@dennisedson&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;this is working code but intead of file path "C:\\Users\\abhimanyu.kumar\\Downloads\\1.png" I wasnt to send bytes like&lt;BR /&gt;var file = new ByteArrayContent(File.ReadAllBytes("C:\\Users\\abhimanyu.kumar\\Downloads\\1.png"));&lt;BR /&gt;file.Headers.Add("Content-Type", "application/octet-stream");&lt;BR /&gt;And I am trying it and response I am getting is &lt;STRONG&gt;unspupported type&lt;BR /&gt;&lt;BR /&gt;What is supported type for file?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Working Code:&lt;/STRONG&gt;&lt;BR /&gt;var options1 = new { access = "PUBLIC_INDEXABLE" };&lt;/P&gt;&lt;P&gt;var properties1 = JsonConvert.SerializeObject(options1);&lt;BR /&gt;var request1 = new RestRequest(Method.POST);&lt;BR /&gt;var client = new RestClient("&lt;A href="http://api.hubapi.com/files/v3/files?hapikey=demo" target="_blank"&gt;http://api.hubapi.com/files/v3/files?hapikey=demo&lt;/A&gt;");&lt;BR /&gt;request1.AddFile("file", "C:\\Users\\abhimanyu.kumar\\Downloads\\1.png");&lt;BR /&gt;request1.AddParameter("folderId", "381726034078");&lt;BR /&gt;request1.AddParameter("options", properties1);&lt;BR /&gt;IRestResponse response1 = client.Execute(request1);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 11:02:33 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390521#M38525</guid>
      <dc:creator>Abhimanyu</dc:creator>
      <dc:date>2020-12-02T11:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390552#M38529</link>
      <description>&lt;P&gt;Maybe the file header is wrong but if you found a way to do it it's a good new. C# is not my main programming lang, i use to learn at university but now i'm most of the time doing nodeJs and php&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 13:15:44 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390552#M38529</guid>
      <dc:creator>quentin_lamamy</dc:creator>
      <dc:date>2020-12-02T13:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390741#M38548</link>
      <description>&lt;P&gt;I am sending the file header 'application/octet-stream' as mention in the document&amp;nbsp;&amp;nbsp;&lt;A href="https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file?_ga=2.255046920.1059212467.1604502924-1273358196.1598626193" target="_blank" rel="noopener"&gt;https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file?_ga=2.255046920.1059212467.1604502924-1273358196.1598626193&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;And are you sending the path of the file or bytes?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 20:39:33 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390741#M38548</guid>
      <dc:creator>Abhimanyu</dc:creator>
      <dc:date>2020-12-02T20:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390893#M38564</link>
      <description>&lt;P&gt;Why are you using the old api ?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 10:17:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/390893#M38564</guid>
      <dc:creator>quentin_lamamy</dc:creator>
      <dc:date>2020-12-03T10:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/391196#M38613</link>
      <description>&lt;P&gt;I am using this api:&amp;nbsp;&lt;A href="http://api.hubapi.com/files/v3/files?hapikey=key" target="_blank"&gt;http://api.hubapi.com/files/v3/files?hapikey=key&lt;/A&gt;&lt;BR /&gt;Main issue is file.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 04:12:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/391196#M38613</guid>
      <dc:creator>Abhimanyu</dc:creator>
      <dc:date>2020-12-04T04:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/391244#M38620</link>
      <description>&lt;P&gt;I send a message to someone from the hubspot team, maybe he can help you&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 10:50:11 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/391244#M38620</guid>
      <dc:creator>quentin_lamamy</dc:creator>
      <dc:date>2020-12-04T10:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/391302#M38627</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/150567"&gt;@Abhimanyu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the issue is that the overall request should use the content type of&amp;nbsp; multipart/form-data. Then the file itself should have applicaiton/octet-stream.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 14:57:11 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/391302#M38627</guid>
      <dc:creator>zwolfson</dc:creator>
      <dc:date>2020-12-04T14:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Upload a file using api In C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/391497#M38644</link>
      <description>&lt;P&gt;Hi finally I am to to upload bytes to hubspot in C#&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Working code&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var file = File.ReadAllBytes("C:\\Users\\abhimanyu.kumar\\Downloads\\1.png");&lt;BR /&gt;var request = new RestRequest(Method.POST);&lt;BR /&gt;var client = new RestClient("&lt;A href="http://api.hubapi.com/files/v3/files?hapikey=key" target="_blank"&gt;http://api.hubapi.com/files/v3/files?hapikey=key&lt;/A&gt;");&lt;/P&gt;&lt;P&gt;request.AddFile("file", file, "FileName.png", "application/octet-stream");&lt;/P&gt;&lt;P&gt;request.AddParameter("folderPath", "/path");&lt;BR /&gt;request.AddParameter("options", properties);&lt;BR /&gt;IRestResponse response = client.Execute(request);&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 17:40:37 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Upload-a-file-using-api-In-C/m-p/391497#M38644</guid>
      <dc:creator>Abhimanyu</dc:creator>
      <dc:date>2020-12-05T17:40:37Z</dc:date>
    </item>
  </channel>
</rss>

