HAPI Key and Write Permissions for Test Portal


#1

Hi I created a test portal for testing an integration, after that I created a HAPI key for that test portal.

When making a write request to https://api.hubapi.com/contacts/v1/contact/email/${email}/profile?hapikey=${hapiKey}, I get the error 'This hapikey (xxx) does not have proper permissions! (requires all of [contacts-write]).

How do I get this permission onto the HAPI key for my test portal?


#3

Hi @matthew, the endpoint you're using can only be used to GET contacts by email. If you're looking to create contacts you should use the Create a new contact endpoint, or the Forms API if you need to track the source of a contact. More on the forms api:

  1. https://developers.hubspot.com/docs/methods/forms/submit_form
  2. https://developers.hubspot.com/docs/methods/forms/submit_form_ajax

#4

Hey Connor, thanks for your reply but this is the end point I was using


Says I should be able to update contact by email


#5

Whoops! Sorry @matthew, I'll chalk that one up to my Wednesday brain :grimacing:

In that case, can you send over the following:

  1. The full request URL you used, including the method (you can omit the Hapikey).
  2. The raw request body you're sending, including the headers.
  3. Your Hub ID.

Thanks!


#6

np!

https://api.hubapi.com/contacts/v1/contact/email/bh@hubspot.com/profile?hapikey=${apiKey}
Method- POST
Headers-

content-type: application/json

Body -

{
"properties": [
{
"property": "firstname",
"value": "My New Name"
},
{
"property": "lastname",
"value": "My New REcord"
}
]
}

Hub ID: 4919226
App ID: 180772


#7

Hi @matthew, thanks for that info! So the issue I think is that you're submitting that POST request your Dev Portal. Dev Portals do not inherently have scopes to the CRM or to any of the normal HubSpot Objects. They are simply there to create applications and monitor them for things like the CRM extensions API, timeline events API, webhooks and others. You'll need to create a test portal (https://developers.hubspot.com/docs/faq/how-do-i-create-a-test-portal) or test out your request to a live HubSpot portal that has access to the CRM. Let me know if you have questions.


#8

I created a test portal already, the HAPI key is for the test portal.

Sorry, I realized I might have sent the wrong HUB ID earlier


#9

Hi @matthew, I was able to successfully make a POST request using the following in Postman:

URL: https://api.hubapi.com/contacts/v1/contact/email/bh@hubspot.com/profile?hapikey=xxxxxxxxxxx
Method: POST
Body:

{
  "properties": [
    {
      "property": "lastname",
      "value": "H - Test"
    }
  ]
}

Headers: Content-Type: application/json

You can see this contact here: https://app.hubspot.com/contacts/4929475/contact/51/?interaction=note.

Make sure you have the content type set to application/json in the header and make sure the hapikey is from your test portal which you can find here: https://app.hubspot.com/integrations-beta/4929475/your-integrations/api-key. Yours should start with cd4d07 and have a bunch of extra characters after.