Attaching File to Company

companies

#1

Is it possible to upload or link a file to the attachment section of a company using the API. We have several attached files in our other CRM that I’m trying to transfer over.


#3

@seb_fairchild I can’t seem to get this to work, are you sure that’s the right format for the attachments? I don’t see an attachments property returned in the associations after adding the engagement.

["associations"]=>
    object(stdClass)#121768 (5) {
      ["contactIds"]=>
      array(1) {
        [0]=>
        int(29280)
      }
      ["companyIds"]=>
      array(0) {
      }
      ["dealIds"]=>
      array(0) {
      }
      ["ownerIds"]=>
      array(0) {
      }
      ["workflowIds"]=>
      array(0) {
      }
    }

#4

@James_Bathgate

You can only add attachments to an engagement with the parameter type:NOTE. If the engagement is a note you should get an attachments array in the response even if the engagement doesn’t have an attachment.

Sebastian


#5

@seb_fairchild I’m using type:NOTE, I’ll come up with an example just using curl.


#6

@seb_fairchild

Here’s an example curl request:

curl -v -X POST -H "Content-Type: application/json" -A "SearchSpring HubSpot API" -d '{"engagement":{"active":true,"ownerId":null,"type":"NOTE","timestamp":1469116690000},"associations":{"contactIds":[29280],"attachments":[{"id":4241968539}]},"metadata":{"body":"<strong>IMPORTED FROM NUTSHELL<\/strong>"}}' https://api.hubapi.com/engagements/v1/engagements?hapikey=my-api-key 

The response I’m getting does not have the attachments array:

{"engagement":{"id":131442414,"portalId":492396,"active":true,"createdAt":1469118333628,"lastUpdated":1469118333628,"ownerId":0,"type":"NOTE","timestamp":1469116690000},"associations":{"contactIds":[29280],"companyIds":[],"dealIds":[],"ownerIds":[],"workflowIds":[]},"metadata":{"body":"<strong>IMPORTED FROM NUTSHELL</strong>"}}

#7

Any response to this? I’ve provided a reproducible test case.


#8

Hey @James_Bathgate

attachments should not be part of the associations object.

try this payload instead:

{
  "engagement": {
    "active": true,
    "type": "NOTE"
  },
  "associations": {
    "contactIds": [
      29280
    ],
    "companyIds": [],
    "dealIds": [],
    "ownerIds": [],
    "workflowIds": []
  },
  "attachments": [
    {
      "id": 4241968539
    }
  ],
  "metadata": {
    "body": "<strong>IMPORTED FROM NUTSHELL</strong>"
  }
}

Sebastian


#9

@seb_fairchild That works, thank you.