APIs & Integrations

ELove
Member

/crm/v3/imports: Unable to process JSON

SOLVE

I'm using the API call /crm/v3/imports to import contacts. I'm sending in POST data with importRequest (JSON data) and a file. Trying to get a very simple file to import, after which I'll add all the columns.

 

The importRequest is: {"name":"Teems contacts","files":[{"filename":"hubspot_people.csv","fileFormat":"CSV","fileImportPage":{"hasHeader":true,"columnMappings":[{"columnObjectTypeId":"0-1","columnName":"first_name","propertyName":"firstname"},{"columnObjectTypeId":"0-1","columnName":"last_name","propertyName":"lastname"}]}}]}


The request returns: {"status":"error","message":"Unable to process JSON","correlationId":"143fb8d1-9245-4eaf-9fa8-f4347542be4c"}

 

I know the file is getting through because when I send the same curl request to my server, I can read the file (and the json). I previously got past other errors (415, 400) but this one isn't showing 4xx, just this error.

0 Upvotes
1 Accepted solution
ELove
Solution
Member

/crm/v3/imports: Unable to process JSON

SOLVE

I've got it working, and I'll note a few things for anyone who comes across this later.

I copied the Postman request (thanks Jaycee) and got that running with my CSV file.

Using Postman's feature to convert the request to PHP code, I copied some of that out and was trying to get it to work.

At one stage, I got "Unable to process JSON" when I had invalid JSON, so that seems to be what that error message indicates, which seems obvious, but I wasn't expecting that, because I had been passing in the return of PHP's json_encode, which should have been valid JSON, so I had assumed the error message meant "Something is wrong in importRequest".

I copied the whole PHP out of Postman and changed a few things and got it working.

View solution in original post

0 Upvotes
4 Replies 4
ELove
Solution
Member

/crm/v3/imports: Unable to process JSON

SOLVE

I've got it working, and I'll note a few things for anyone who comes across this later.

I copied the Postman request (thanks Jaycee) and got that running with my CSV file.

Using Postman's feature to convert the request to PHP code, I copied some of that out and was trying to get it to work.

At one stage, I got "Unable to process JSON" when I had invalid JSON, so that seems to be what that error message indicates, which seems obvious, but I wasn't expecting that, because I had been passing in the return of PHP's json_encode, which should have been valid JSON, so I had assumed the error message meant "Something is wrong in importRequest".

I copied the whole PHP out of Postman and changed a few things and got it working.

0 Upvotes
ELove
Member

/crm/v3/imports: Unable to process JSON

SOLVE

I tried now with "First Name" and "Last Name", but with the same result. first_name and last_name are the column headings in my CSV.

 

Here are the contents of the CSV:

 

contact_id,first_name,last_name
8420,Russell,Hitch
8599,Stan,Haoust

 

Eventually this will be all the records and many more fields, but I'm trying to get a minimum request working. 

 

What class of wrong inputs yield a message of "Unable to process JSON"?

 

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

/crm/v3/imports: Unable to process JSON

SOLVE

Hey, @ELove I tried a quick test using Postman and a simple three column/one row sheet. Here's what I did:

  • created my sheet
    CleanShot 2025-01-27 at 10.04.45@2x.png
  • Used the example JSON from the dev docs — Import one file with one object 
  • Setup Postman according to the above dev doc example
    CleanShot 2025-01-27 at 10.07.27@2x.png
  • JSON I used for `importRequest` (updating import and file name to match my sheet
    {
      "name": "import_test_1",
      "importOperations": {
        "0-1": "CREATE"
      },
      "dateFormat": "DAY_MONTH_YEAR",
      "files": [
        {
          "fileName": "bbTest - Sheet1.csv",
          "fileFormat": "CSV",
          "fileImportPage": {
            "hasHeader": true,
            "columnMappings": [
              {
                "columnObjectTypeId": "0-1",
                "columnName": "First Name",
                "propertyName": "firstname"
              },
              {
                "columnObjectTypeId": "0-1",
                "columnName": "Last Name",
                "propertyName": "lastname"
              },
              {
                "columnObjectTypeId": "0-1",
                "columnName": "Email",
                "propertyName": "email",
                "columnType": "HUBSPOT_ALTERNATE_ID"
              }
            ]
          }
        }
      ]
    }


  • Received a successful response
    {
        "state": "STARTED",
        "importRequestJson": {
            "portalId": 22245342,
            "language": "en-us",
            "numberFormatLocale": {
                "language": "en",
                "country": "US"
            },
            "dateFormat": "DAY_MONTH_YEAR",
            "timeZone": "Z",
            "importOperations": {
                "0-1": "CREATE"
            },
            "invalidPropertyValues": [],
            "remappedValues": [],
            "importName": "import_test_1",
            "fileImports": [
                {
                    "columnDelimiter": ",",
                    "estimatedLineCount": 1,
                    "fileFormat": "CSV",
                    "charset": "UTF-8",
                    "fileId": 185420314805,
                    "pages": [
                        {
                            "columnMappings": [
                                {
                                    "columnObjectTypeId": "0-1",
                                    "columnName": "First Name",
                                    "propertyName": "firstname",
                                    "ignored": false,
                                    "columnType": "STANDARD",
                                    "associationIdentifierColumn": false,
                                    "skipIfKnownColumn": false,
                                    "sensitivityLevel": "none"
                                },
                                {
                                    "columnObjectTypeId": "0-1",
                                    "columnName": "Last Name",
                                    "propertyName": "lastname",
                                    "ignored": false,
                                    "columnType": "STANDARD",
                                    "associationIdentifierColumn": false,
                                    "skipIfKnownColumn": false,
                                    "sensitivityLevel": "none"
                                },
                                {
                                    "columnObjectTypeId": "0-1",
                                    "columnName": "Email",
                                    "propertyName": "email",
                                    "ignored": false,
                                    "columnType": "HUBSPOT_ALTERNATE_ID",
                                    "associationIdentifierColumn": false,
                                    "skipIfKnownColumn": false,
                                    "sensitivityLevel": "none"
                                }
                            ],
                            "additionalColumnMappingAndValues": [],
                            "hasHeader": true
                        }
                    ]
                }
            ],
            "createContactListFromImport": false,
            "source": "API",
            "importNotificationType": "IMPORT_COMPLETED",
            "marketableContactImport": false,
            "skipIfKnownImport": false,
            "shouldApplyBlankValues": false,
            "parentChildCompanyImport": false
        },
        "importSource": "API",
        "metadata": {
            "objectLists": [],
            "counters": {},
            "fileIds": [
                "185420314805"
            ]
        },
        "importName": "import_test_1",
        "mappedObjectTypeIds": [
            "0-1"
        ],
        "optOutImport": false,
        "createdAt": "2025-01-27T17:02:31.971Z",
        "updatedAt": "2025-01-27T17:02:32.149Z",
        "id": "56682874"
    }​
  • Verified the Contact exists in my test portal
    CleanShot 2025-01-27 at 10.10.30@2x.png

I hope this helps! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

/crm/v3/imports: Unable to process JSON

SOLVE

Hey, @ELove 👋 One suggestion — have you tried adjusting your column name to “columnName”: “First Name” versus “columnName”:”first_name”? If you've already tried this, please let me know. It won't hurt my feelings. Knowing what you've ruled out helps narrow down other options to suggest. 

 

Talk soon! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes