# Json parse error when calling import api endpoint using c# and .net

**URL:** <https://community.hubspot.com/t/json-parse-error-when-calling-import-api-endpoint-using-c-and-net/36029>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [April 22, 2021, 11:08pm UTC](https://community.hubspot.com/t/json-parse-error-when-calling-import-api-endpoint-using-c-and-net/36029 "2021-04-22T23:08:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucasrd](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lucasrd/32/82448_2.png) [@lucasrd](https://community.hubspot.com/u/lucasrd)\
**Post date:** [April 22, 2021, 11:08pm UTC](https://community.hubspot.com/t/json-parse-error-when-calling-import-api-endpoint-using-c-and-net/36029/1 "2021-04-22T23:08:58Z")

</div>

I am trying to post a csv file using the import API. I followed an [example here](https://community.hubspot.com/t5/APIs-Integrations/Is-there-an-example-of-how-to-access-the-import-api-endpoint/td-p/365948), but still am getting an “unable to parse json format” error when making the request. Here is my code:

```lia-code-sample
var key = ConfigurationManager.AppSettings["HSAPIKEY"];
 var client = new RestClient(String.Format("https://api.hubapi.com/crm/v3/imports?hapikey={0}", key));

 client.Timeout = -1;

 var request = new RestRequest(Method.POST);
 request.AddHeader("Content-Type", "multipart/form-data");
 request.AddHeader("Cookie", "__cfduid=d09cae7faeb5960760427f1cf3f5bfd7a1597311822");

 string payload = @"{
 ""name"": ""test_import"",
 ""files"": [
 {
 ""fileName"": ""hearing_first_test_2021-04-08.csv"",
 ""fileFormat"": ""CSV"",
 ""fileImportPage"": {
 ""hasHeader"": true,
 ""columnMappings"": [
 {
 ""ignored"": false,
 ""columnName"": ""email_address"",
 ""idColumnType"": ""HUBSPOT_ALTERNATE_ID"",
 ""propertyName"": ""email"",
 ""foreignKeyType"": null,
 ""columnObjectTypeId"":""0-1"",
 ""associationIdentifierColumn"": false
 },
 {
 ""ignored"": false,
 ""columnName"": ""expected_due_date"",
 ""idColumnType"": ""null"",
 ""propertyName"": ""due_date"",
 ""foreignKeyType"": null,
 ""columnObjectTypeId"":""0-1"",
 ""associationIdentifierColumn"": false
 },
 {
 ""ignored"": false,
 ""columnName"": ""first_name"",
 ""idColumnType"": ""null"",
 ""propertyName"": ""firstname"",
 ""columnObjectTypeId"":""0-1"",
 ""associationIdentifierColumn"": false
 },
 {
 ""ignored"": false,
 ""columnName"": ""last_name"",
 ""idColumnType"": ""null"",
 ""propertyName"": ""lastname"",
 ""columnObjectTypeId"":""0-1"",
 ""associationIdentifierColumn"": false
 },
 {
 ""ignored"": false,
 ""columnName"": ""zipcode"",
 ""idColumnType"": ""null"",
 ""propertyName"": ""zip"",
 ""columnObjectTypeId"":""0-1"",
 ""associationIdentifierColumn"": false
 },
 {
 ""ignored"": false,
 ""columnName"": ""source_id"",
 ""idColumnType"": ""null"",
 ""propertyName"": ""bc_wte_contact"",
 ""columnObjectTypeId"":""0-1"",
 ""associationIdentifierColumn"": false
 }
 ]
 }
 }
 ]
 }";

 request.AddParameter("importRequest", payload);
 request.AddFile("files", AppDomain.CurrentDomain.BaseDirectory + "hearing_first_test_2021-04-08.csv");
 request.RequestFormat = DataFormat.Json;

 IRestResponse response = client.Execute(request);

```

The error is:

“{\“status\”:\“error\”,\“message\”:\“Unable to process JSON\”,\“correlationId\”:\“d08507be-2b90-466e-99ec-1b6ab7fb76e9\”}”

The actual JSON generated that I’m posting is below and it validates in online JSON parsers.

```lia-code-sample
{
 "name": "test_import",
 "files": [
 {
 "fileName": "hearing_first_test_2021-04-08.csv",
 "fileFormat": "CSV",
 "fileImportPage": {
 "hasHeader": true,
 "columnMappings": [
 {
 "ignored": false,
 "columnName": "email_address",
 "idColumnType": "HUBSPOT_ALTERNATE_ID",
 "propertyName": "email",
 "foreignKeyType": null,
 "columnObjectTypeId":"0-1",
 "associationIdentifierColumn": false
 },
 {
 "ignored": false,
 "columnName": "expected_due_date",
 "idColumnType": "null",
 "propertyName": "due_date",
 "foreignKeyType": null,
 "columnObjectTypeId":"0-1",
 "associationIdentifierColumn": false
 },
 {
 "ignored": false,
 "columnName": "first_name",
 "idColumnType": "null",
 "propertyName": "firstname",
 "columnObjectTypeId":"0-1",
 "associationIdentifierColumn": false
 },
 {
 "ignored": false,
 "columnName": "last_name",
 "idColumnType": "null",
 "propertyName": "lastname",
 "columnObjectTypeId":"0-1",
 "associationIdentifierColumn": false
 },
 {
 "ignored": false,
 "columnName": "zipcode",
 "idColumnType": "null",
 "propertyName": "zip",
 "columnObjectTypeId":"0-1",
 "associationIdentifierColumn": false
 },
 {
 "ignored": false,
 "columnName": "source_id",
 "idColumnType": "null",
 "propertyName": "bc_wte_contact",
 "columnObjectTypeId":"0-1",
 "associationIdentifierColumn": false
 }
 ]
 }
 }
 ]
 }

```

---

<div class="post-metadata">

**Author:** ![natsumimori](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/natsumimori/32/39807_2.png) [@natsumimori](https://community.hubspot.com/u/natsumimori)\
**Post date:** [April 26, 2021, 6:54am UTC](https://community.hubspot.com/t/json-parse-error-when-calling-import-api-endpoint-using-c-and-net/36029/2 "2021-04-26T06:54:50Z")

</div>

Hi @lucasrd ,

Thank you for reaching out to the HubSpot Community.

@RMones and @Bryantworks , would you mind sharing your advice for @lucasrd ?

---

<div class="post-metadata">

**Author:** ![RMones](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rmones/32/82797_2.png) [@RMones](https://community.hubspot.com/u/RMones)\
**Post date:** [April 26, 2021, 7:25am UTC](https://community.hubspot.com/t/json-parse-error-when-calling-import-api-endpoint-using-c-and-net/36029/3 "2021-04-26T07:25:05Z")

</div>

Hi @lucasrd ,

I think you’ve got this error because of the double double quotes around your strings.

`""name"": ""test_import"",`

Shoud be:

`"name": "test_import",`

You can check if your JSON is valid at [https://jsonformatter.org/](https://jsonformatter.org/) . A nice tool that let you know where the error occours.

Regards Ronald

---

<div class="post-metadata">

**Author:** ![lucasrd](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lucasrd/32/82448_2.png) [@lucasrd](https://community.hubspot.com/u/lucasrd)\
**Post date:** [April 26, 2021, 11:39am UTC](https://community.hubspot.com/t/json-parse-error-when-calling-import-api-endpoint-using-c-and-net/36029/4 "2021-04-26T11:39:53Z")

</div>

@RMones - Thanks, but that is the escape sequence for a multi-line C# literal. I have debugged this in Visual studio and the resulting JSON does parse correctly in an online parser.

---

<div class="post-metadata">

**Author:** ![lucasrd](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lucasrd/32/82448_2.png) [@lucasrd](https://community.hubspot.com/u/lucasrd)\
**Post date:** [April 26, 2021, 1:32pm UTC](https://community.hubspot.com/t/json-parse-error-when-calling-import-api-endpoint-using-c-and-net/36029/5 "2021-04-26T13:32:58Z")

</div>

I figured out the issue. My JSON values which should have been passed as null were passed in as the string “null” and Hubspot didn’t like that.

---

<div class="post-metadata">

**Author:** ![STurbadkar](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sturbadkar/32/43872_2.png) [@STurbadkar](https://community.hubspot.com/u/STurbadkar)\
**Post date:** [March 1, 2022, 7:43am UTC](https://community.hubspot.com/t/json-parse-error-when-calling-import-api-endpoint-using-c-and-net/36029/6 "2022-03-01T07:43:31Z")

</div>

What is the solution for this one? I am getting the same issue
