# HTTP POST IMPORT Failing using C#

**URL:** <https://community.hubspot.com/t/http-post-import-failing-using-c/122765>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [December 18, 2024, 8:01pm UTC](https://community.hubspot.com/t/http-post-import-failing-using-c/122765 "2024-12-18T20:01:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SImadEddine](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@SImadEddine](https://community.hubspot.com/u/SImadEddine)\
**Post date:** [December 18, 2024, 8:01pm UTC](https://community.hubspot.com/t/http-post-import-failing-using-c/122765/1 "2024-12-18T20:01:07Z")

</div>

Hello everyone,  
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.  
Here is the ERROR

`{"status":"error","message":"Unable to process JSON","correlationId":"06cadc87-9dc7-4627-8c25-fe5029c27180"}`

C# CODE

```lia-code-sample
 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();

 }
 }

```

Request.json

```lia-code-sample
// 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"
 //}
 ]
 }
 }
 ]
}

```

hubspot\_sample.csv

```lia-code-sample
Email,Domain
test2@test.com,www.test2.com,

```

Can anyone help what’s wrong ? Thanks

---

<div class="post-metadata">

**Author:** ![SteveHTM](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stevehtm/32/22074_2.png) [@SteveHTM](https://community.hubspot.com/u/SteveHTM)\
**Post date:** [December 18, 2024, 9:34pm UTC](https://community.hubspot.com/t/http-post-import-failing-using-c/122765/2 "2024-12-18T21:34:54Z")

</div>

@SImadEddine - 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.

Steve

---

<div class="post-metadata">

**Author:** ![SImadEddine](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@SImadEddine](https://community.hubspot.com/u/SImadEddine)\
**Post date:** [December 18, 2024, 9:54pm UTC](https://community.hubspot.com/t/http-post-import-failing-using-c/122765/3 "2024-12-18T21:54:17Z")

</div>

Hi Steve,  
It is client side, just testing console app in my visual studio at the moment

---

<div class="post-metadata">

**Author:** ![SteveHTM](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stevehtm/32/22074_2.png) [@SteveHTM](https://community.hubspot.com/u/SteveHTM)\
**Post date:** [December 18, 2024, 9:58pm UTC](https://community.hubspot.com/t/http-post-import-failing-using-c/122765/4 "2024-12-18T21:58:56Z")

</div>

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.

Good luck!

Steve

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [December 18, 2024, 9:57pm UTC](https://community.hubspot.com/t/http-post-import-failing-using-c/122765/5 "2024-12-18T21:57:37Z")

</div>

Hi @SImadEddine 👋

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 🤞

Please let me know if you have any follow-up questions.

---

<div class="post-metadata">

**Author:** ![SImadEddine](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@SImadEddine](https://community.hubspot.com/u/SImadEddine)\
**Post date:** [December 19, 2024, 8:20am UTC](https://community.hubspot.com/t/http-post-import-failing-using-c/122765/6 "2024-12-19T08:20:24Z")

</div>

Hi Zach, that’s true thank you
