APIs & Integrations

EMCC
Membre

Why it says hapikey does not exist when trying to make the API call request ?

Hello,

I am trying to implement the contact creation API using a html form to capture leads. I have created the API key by creating the private app in my hubspot account. But when i am using that particular API key to make the request API call it says api key does not exist. 


Can anyone help me with this?

MY ENDPOINT: 

$endpoint = 'https://api.hubapi.com/contacts/v1/contact?hapikey=XXX-XXX-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';

Error:

curl Errors: Status code: 401 Response: {"status":"error","message":"This hapikey doesn't exist.","correlationId":"c8ba6603-59a8-43f7-bbda-8330085593af"}

0 Votes
3 Réponses
Jaycee_Lewis
Gestionnaire de communauté
Gestionnaire de communauté

Why it says hapikey does not exist when trying to make the API call request ?

Hey, @EMCC 👋 If you've already made the switch to Private Apps, which it sounds like you did, then you'll need to include your private app key in your header and not in the request URL. 

 

Here's a quick test I ran using Postman:

  • Created Private App in my app test account
  • Used this endpoint — Create a new Contact
    POST /contacts/v1/contact​
  • My request
    Request Headers
    Authorization: "Bearer MY_PRIVATE_APP"
    Content-Type: "application/json"
    
    Request Body
    {
        "properties": [
            {
                "property": "email",
                "value": "testingapis111@cat.com"
            },
            {
                "property": "firstname",
                "value": "TyTy"
            },
            {
                "property": "lastname",
                "value": "Cat"
            }
        ]
    }
    ​
  • Which returns a 200OK response

In summary, you'll need to treat your private app key like an OAuth token and include in your request header. More info here:

Have fun building! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Votes
LeeBartelme
HubSpot Employee
HubSpot Employee

Why it says hapikey does not exist when trying to make the API call request ?

The API key method for authentication is being sunset at the end of November and new development really should take place using private apps and a token. In that case you'll use your private app token in an Authorization header. I know this doesn't answer your question, but if you are working on new items you'll have to change it very soon. I don't know how much support you'll get using the depreciated method.

I can't tell if the error is saying the key is "invalid" i.e. THIS hapikey doesn't exist or if it can't find it in the request. I'd verify you are using the correct key. 

0 Votes
Jaycee_Lewis
Gestionnaire de communauté
Gestionnaire de communauté

Why it says hapikey does not exist when trying to make the API call request ?

Hey, @LeeBartelme I think this error is telling us that they put the private app key in the request URL, like you do for an API key, instead of including it in the request header. 

 

Thanks for taking the time to help @EMCC  🙌 I appreciate you!

 

 

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Votes