<?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: HTTP POST IMPORT Failing using C# in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085289#M79014</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/872805"&gt;@SImadEddine&lt;/a&gt;&amp;nbsp;- can I ask in what execution environment are you calling these code fragments? My question is related to whether it is server side (within HubSpot) or client side.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;</description>
    <pubDate>Wed, 18 Dec 2024 21:34:54 GMT</pubDate>
    <dc:creator>SteveHTM</dc:creator>
    <dc:date>2024-12-18T21:34:54Z</dc:date>
    <item>
      <title>HTTP POST IMPORT Failing using C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085247#M79011</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'm trying to implement HTTP POST to import CSV data but always getting errors. i tried to follow similar subjects here but no success.&amp;nbsp;&lt;BR /&gt;Here is the ERROR&amp;nbsp;&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;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="javascript"&gt;{"status":"error","message":"Unable to process JSON","correlationId":"06cadc87-9dc7-4627-8c25-fe5029c27180"}&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;&amp;nbsp;&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;P&gt;C# CODE&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="csharp"&gt;        private readonly string filePath = @"..\net8.0\Data\hubspot_sample.csv";
        private readonly string requestJsonPath = @"..\net8.0\Data\request.json";


        public async Task UploadCSV()
        {

            var importRequest = System.IO.File.ReadAllText(requestJsonPath);

            var formContent = new MultipartFormDataContent();
            formContent.Add(
                new StringContent(
                        importRequest,
                        System.Text.Encoding.UTF8,
                        "application/json"),
                "importRequest");

            // importFiles is a string[] of full file paths

                formContent.Add(
                    new StreamContent(System.IO.File.OpenRead(filePath)),
                    "files",
                    Path.GetFileName(filePath));

            var requestMessage = new HttpRequestMessage(
                                HttpMethod.Post,
                                "https://api.hubapi.com/crm/v3/imports"
                       )
            {
                Content = formContent
            };

            requestMessage.Headers.Add("Authorization", $"Bearer {API_KEY}");

            requestMessage.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            var response = await new HttpClient().SendAsync(requestMessage);
            if (response.Content != null)
            {
                var jsonResponse = await response.Content.ReadAsStringAsync();
               
            }
        }&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Request.json&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&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;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="javascript"&gt;// Example POST to https://api.hubspot.com/crm/v3/imports
// Content-Type header set to multipart/form-data

{
  "name": "Association Label Import",
  "dateFormat": "DAY_MONTH_YEAR",
  "files": [
    {
      "fileName": "hubspot_sample.csv",
      "fileFormat": "CSV",
      "fileImportPage": {
        "hasHeader": true,
        "columnMappings": [
          {
            "columnObjectTypeId": "0-1",
            "columnName": "Email",
            "propertyName": "email"
          },
          {
            "columnObjectTypeId": "0-2",
            "columnName": "Domain",
            "propertyName": "domain"
          }
          //,
          //{
          //  "columnName": "Association Label",
          //  "columnType": "FLEXIBLE_ASSOCIATION_LABEL",
          //  "columnObjectTypeId": "0-1",
          //  "toColumnObjectTypeId": "0-2"
          //}
        ]
      }
    }
  ]
}&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;&amp;nbsp;&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;P&gt;hubspot_sample.csv&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&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;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="markup"&gt;Email,Domain
test2@test.com,www.test2.com,&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;&amp;nbsp;&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;BR /&gt;&lt;BR /&gt;Can anyone help what's wrong ? Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 20:03:30 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085247#M79011</guid>
      <dc:creator>SImadEddine</dc:creator>
      <dc:date>2024-12-18T20:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP POST IMPORT Failing using C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085289#M79014</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/872805"&gt;@SImadEddine&lt;/a&gt;&amp;nbsp;- can I ask in what execution environment are you calling these code fragments? My question is related to whether it is server side (within HubSpot) or client side.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 21:34:54 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085289#M79014</guid>
      <dc:creator>SteveHTM</dc:creator>
      <dc:date>2024-12-18T21:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP POST IMPORT Failing using C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085304#M79019</link>
      <description>Hi Steve,&lt;BR /&gt;It is client side, just testing console app in my visual studio at the moment&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Dec 2024 21:54:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085304#M79019</guid>
      <dc:creator>SImadEddine</dc:creator>
      <dc:date>2024-12-18T21:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP POST IMPORT Failing using C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085307#M79020</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/872805"&gt;@SImadEddine&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you tried removing the commented-out lines in your Request.json file? I've found some HubSpot API endpoints respond with errors when there are comments included in JSON. Hopefully it's as simple as that &lt;span class="lia-unicode-emoji" title=":crossed_fingers:"&gt;🤞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if you have any follow-up questions.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 21:57:37 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085307#M79020</guid>
      <dc:creator>zach_threadint</dc:creator>
      <dc:date>2024-12-18T21:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP POST IMPORT Failing using C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085308#M79021</link>
      <description>&lt;P&gt;Its hard for me to follow all the flow in your code framents - but something that has always given me problems with this API is the header of the request. It should NOT contain application/json I believe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 21:58:56 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085308#M79021</guid>
      <dc:creator>SteveHTM</dc:creator>
      <dc:date>2024-12-18T21:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP POST IMPORT Failing using C#</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085443#M79044</link>
      <description>&lt;P&gt;Hi Zach, that's true thank you&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2024 08:20:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/HTTP-POST-IMPORT-Failing-using-C/m-p/1085443#M79044</guid>
      <dc:creator>SImadEddine</dc:creator>
      <dc:date>2024-12-19T08:20:24Z</dc:date>
    </item>
  </channel>
</rss>

