Hi, I'm trying to build a workflow that integrates with Hubspot's Import API. It seems like there is a bug with the connector, in particular the files
attribute of the component:
Is the files
attribute supported to take in a similar object as the REST form? In other words, say I have a data object foo
like
{
"data": "YOUR CONTENT HERE",
"name": "foo.csv",
"type":"text/csv"
}
If so, Hubspot 4xxed with the input {{data}}
, showing in its request log:
--form-data-boundary-iyoo4rbit13aihcp
Content-Disposition: form-data; name="files"
{"data":"user_id,user_email,csv continues","name":"foo.csv","type":"text/csv"}
If I change my input to just do the data above, e.g. `{{data.data}}, I get:
--form-data-boundary-3rw8v1pe95v457qi
Content-Disposition: form-data; name="files"
user_id,user_email,csv continues
That also 4xxed. While closer to the "correct" request, it is missing the filename, which the API needs as part of its API call.
Is this a bug?
Ultimately, like my other issue posted recently, I had to recreate the API call with a python request code block, exposing my credentials within the Workflow. :(. Python code snippit here:
import requests
import json
url = "https://api.hubapi.com/crm/v3/imports/"
headers = {'Authorization': 'Bearer 12345'}
output = []
for file in Remap_Data.data:
files = {'files': (file['name'], file['data'], 'text/csv')}
data = {'importRequest': json.dumps(PreparedImportRequest.data) }
response = requests.post(url, files=files, data=data, headers=headers)
# Handle the response
if response.status_code == 200:
response_json = response.json()
return response_json;
return output