APIs & Integrations

MCalegher
Member

(415) Unsupported Media Type when POST a Import

SOLVE

I'm in the process of trying to begin integrating HubSpot with an external application from which I am trying to upload CSV formatted data to create an import .

Language: Python

 

url = "https://api.hubapi.com/crm/v3/imports"
headers = {
        'authorization': 'Bearer %s' % ApiKey,
        'Content-Type': 'application/json'
    }
response = requests.request("POST", url,headers=headers, data=payload, files=files)

 

the payload is

 

{
    "name": "IMPORT xxx",
    "dateFormat": "DAY_MONTH_YEAR",
    "files": [
        {
            "fileName": "import_xxx.csv",
            "fileFormat": "CSV",
            "fileImportPage": {
                "hasHeader": True,
                "columnMappings": [
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Chiave",
                        "propertyName": "chiave",
                        "idColumnType": None
                    },
                    {
                       "columnObjectTypeId": "0-1",
                        "columnName": "Nome",
                        "propertyName": "firstname",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Telefono",
                        "propertyName": "phone",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Cellulare",
                        "propertyName": "mobilephone",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Email",
                        "propertyName": "email",
                        "idColumnType": "HUBSPOT_ALTERNATE_ID"
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Marca",
                        "propertyName": "marca",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Modello",
                        "propertyName": "modello",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Versione",
                        "propertyName": "versione",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Filiale",
                        "propertyName": "filiale",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Venditore",
                        "propertyName": "venditore",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Provincia",
                        "propertyName": "provincia",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Data Contratto",
                        "propertyName": "data_contratto",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Citta",
                        "propertyName": "city",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Con Permute",
                        "propertyName": "con_permute",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Indirizzo",
                        "propertyName": "address",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Targa",
                        "propertyName": "targa",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Magic Cliente",
                        "propertyName": "magic_cliente",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Magic Societa",
                        "propertyName": "magic_societa",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Data Preventivo",
                        "propertyName": "data_preventivo",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "Cliente After Sales",
                        "propertyName": "cliente_after_sales",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "timestamp_ultima_modifica",
                        "propertyName": "data_ultima_modifica_gino",
                        "idColumnType": None
                    },
                    {
                        "columnObjectTypeId": "0-1",
                        "columnName": "duplicate",
                        "propertyName": "duplicate",
                        "idColumnType": None
                    }
                ]
            }
        }
    ]
}

 

the file is a correct CSV

I update the authorization method of your integration's API requests with doc at: migration 

Then error is:

415 Client Error: Unsupported Media Type for url: https://api.hubapi.com/crm/v3/imports

 

Unfortunately the documentation is not complete....

Imports Doc 

 

image.png

 

From this information, can you see any issues in what I am doing? Please let me know if more information is required.

thks

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Community Manager
Community Manager

(415) Unsupported Media Type when POST a Import

SOLVE

Hi, @MCalegher 👋 Can you set your Content-Type header to 

multipart/form-data

and try again? 

 

I found it in the documentation, but it was a bit tucked away — “For the request header, add a Content-Type header with a value of multipart/form-data.

 

Hey, @tominal, am I missing anything obvious here?

 

 Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

View solution in original post

0 Upvotes
3 Replies 3
Jaycee_Lewis
Solution
Community Manager
Community Manager

(415) Unsupported Media Type when POST a Import

SOLVE

Hi, @MCalegher 👋 Can you set your Content-Type header to 

multipart/form-data

and try again? 

 

I found it in the documentation, but it was a bit tucked away — “For the request header, add a Content-Type header with a value of multipart/form-data.

 

Hey, @tominal, am I missing anything obvious here?

 

 Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
MCalegher
Member

(415) Unsupported Media Type when POST a Import

SOLVE

Thanks😀

0 Upvotes
tominal
Guide | Partner
Guide | Partner

(415) Unsupported Media Type when POST a Import

SOLVE

I would bet that's it!


Thomas Johnson
Community Champion


Kahu Software LLC
A Texan HubSpot consulting firm
https://kahusoftware.com