APIs & Integrations

CBryant4
Participant

Problem with creating associations (v4)

SOLVE

I seem to be unable to create associations between Contacts and a custom object.

 

Here is the URI I am sending (note: I have xxxed out the api key):

 

 

https://api.hubapi.com/crm/v4/objects/Contact/339219/associations/2-6971002/1799341940?hapikey=xxxxx

 

Here, I am trying to associate a Contact object with ID 339219 to a BankingProduct object (a custom object we've created whose type id is 2-6971002) with id 1799341940.

 

I receive a 500 Internal Server Error.  What am I doing wrong?  I tried using "contacts" instead of the singular "contact", but that didn't work.  I also tried doing this in the opposite direction (i.e. associating the (custom) BankingProduct record with the Contact), but that gave the same error.


Here is the full response:

 

 

{"Request":{"AlwaysMultipartFormData":false,"MultipartFormQuoteParameters":false,"FormBoundary":null,"Parameters":[{"Name":"hapikey","Value":"xxx","Type":4,"Encode":true,"ContentType":null},{"Name":"objectType","Value":"2-6971002","Type":1,"Encode":true,"ContentType":null},{"Name":"objectId","Value":"1801002839","Type":1,"Encode":true,"ContentType":null},{"Name":"toObjectType","Value":"Contact","Type":1,"Encode":true,"ContentType":null},{"Name":"toObjectId","Value":"339219","Type":1,"Encode":true,"ContentType":null}],"Files":[],"Method":2,"Timeout":0,"Resource":"https://api.hubapi.com/crm/v4/objects/{objectType}/{objectId}/associations/{toObjectType}/{toObjectId}","RequestFormat":0,"RootElement":null,"OnBeforeDeserialization":null,"OnBeforeRequest":null,"OnAfterRequest":null,"Attempts":1,"CompletionOption":0,"ResponseWriter":null,"AdvancedResponseWriter":null},"ContentType":"application/json","ContentLength":100,"ContentEncoding":[],"Content":"{\"status\":\"error\",\"message\":\"internal error\",\"correlationId\":\"aaeb6df8-9ce2-4aa4-9a73-21eb8736a541\"}","StatusCode":500,"IsSuccessful":false,"StatusDescription":"Internal Server Error","RawBytes":"eyJzdGF0dXMiOiJlcnJvciIsIm1lc3NhZ2UiOiJpbnRlcm5hbCBlcnJvciIsImNvcnJlbGF0aW9uSWQiOiJhYWViNmRmOC05Y2UyLTRhYTQtOWE3My0yMWViODczNmE1NDEifQ==","ResponseUri":"https://api.hubapi.com/crm/v4/objects/2-6971002/1801002839/associations/Contact/339219?hapikey=2e3f39fb-2b46-4e62-a8b3-f83c16219b6e","Server":"cloudflare","Cookies":[],"Headers":[{"Name":"Date","Value":"Tue, 05 Jul 2022 21:00:13 GMT","Type":2,"Encode":false,"ContentType":null},{"Name":"Connection","Value":"keep-alive","Type":2,"Encode":false,"ContentType":null},{"Name":"CF-Ray","Value":"726307650857062f-IAD","Type":2,"Encode":false,"ContentType":null},{"Name":"Strict-Transport-Security","Value":"max-age=31536000; includeSubDomains; preload","Type":2,"Encode":false,"ContentType":null},{"Name":"Vary","Value":"Accept-Encoding","Type":2,"Encode":false,"ContentType":null},{"Name":"CF-Cache-Status","Value":"DYNAMIC","Type":2,"Encode":false,"ContentType":null},{"Name":"Access-Control-Allow-Credentials","Value":"false","Type":2,"Encode":false,"ContentType":null},{"Name":"Expect-CT","Value":"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"","Type":2,"Encode":false,"ContentType":null},{"Name":"X-HubSpot-Correlation-Id","Value":"aaeb6df8-9ce2-4aa4-9a73-21eb8736a541","Type":2,"Encode":false,"ContentType":null},{"Name":"X-HubSpot-RateLimit-Daily","Value":"500000","Type":2,"Encode":false,"ContentType":null},{"Name":"X-HubSpot-RateLimit-Daily-Remaining","Value":"420263","Type":2,"Encode":false,"ContentType":null},{"Name":"X-HubSpot-RateLimit-Interval-Milliseconds","Value":"10000","Type":2,"Encode":false,"ContentType":null},{"Name":"X-HubSpot-RateLimit-Max","Value":"150","Type":2,"Encode":false,"ContentType":null},{"Name":"X-HubSpot-RateLimit-Remaining","Value":"147","Type":2,"Encode":false,"ContentType":null},{"Name":"X-HubSpot-RateLimit-Secondly","Value":"15","Type":2,"Encode":false,"ContentType":null},{"Name":"X-HubSpot-RateLimit-Secondly-Remaining","Value":"14","Type":2,"Encode":false,"ContentType":null},{"Name":"X-Trace","Value":"2B4C01E5C5C8320FD3A8B862615D185CE7A96E0689000000000000000000","Type":2,"Encode":false,"ContentType":null},{"Name":"Report-To","Value":"{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=Gzf9WBQ4UKLegsA5nKLVIrnQJIHWa5VLuIzfb4bBSxtN6snI%2FG648r1biOt8hulyI%2FZbM2FYlHbk3H%2Fcm203BYWG889N1xz8CK5%2FejhipX5A%2F6EfW1fB7YCthzorrV6V\"}],\"group\":\"cf-nel\",\"max_age\":604800}","Type":2,"Encode":false,"ContentType":null},{"Name":"NEL","Value":"{\"success_fraction\":0.01,\"report_to\":\"cf-nel\",\"max_age\":604800}","Type":2,"Encode":false,"ContentType":null},{"Name":"Server","Value":"cloudflare","Type":2,"Encode":false,"ContentType":null},{"Name":"Alt-Svc","Value":"h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400","Type":2,"Encode":false,"ContentType":null}],"ContentHeaders":[{"Name":"Content-Type","Value":"application/json; charset=utf-8","Type":2,"Encode":false,"ContentType":null},{"Name":"Content-Length","Value":"100","Type":2,"Encode":false,"ContentType":null}],"ResponseStatus":2,"ErrorMessage":null,"ErrorException":{"StackTrace":null,"Message":"Request failed with status code InternalServerError","Data":{},"InnerException":null,"HelpLink":null,"Source":null,"HResult":-2146233088},"Version":"1.1","RootElement":null}

 

 

Any idea what I am doing wrong?

0 Upvotes
1 Accepted solution
CBryant4
Solution
Participant

Problem with creating associations (v4)

SOLVE

@dennisedson thanks for following up.  I've fixed this already.  It was my error - I had forgotten that I needed to create the association definition first. 🙂

View solution in original post

2 Replies 2
CBryant4
Solution
Participant

Problem with creating associations (v4)

SOLVE

@dennisedson thanks for following up.  I've fixed this already.  It was my error - I had forgotten that I needed to create the association definition first. 🙂

dennisedson
HubSpot Product Team
HubSpot Product Team

Problem with creating associations (v4)

SOLVE

@CBryant4 , what did you send in the JSON body?

0 Upvotes