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