Unauthorized

SOLVE
Highlighted
Occasional Contributor

i have a rest service  is locate in a host with certificate http and i try to consume the api hubspot but when i send a request i have a issue.

this is  the error:

The remote server returned an error: 401 Unauthorized, but in my local works fine.

I dont now what is the problem.

 

 

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Community Manager

Hi @dianacch ,

 

Apologies for the delay here. As far as I understand, it's not required that your client has an SSL certificate in order to make requests to the HubSpot API. This appears to be validated in this stack overflow article. That said, I'm not really clear on what exactly is happening here. A 401 with a hapikey almost always means one of two things:

  1. The request is being malformed in some way, so that the hapikey isn't being properly included
  2. The hapikey is a developer hapikey (from a developer account) and is used to make requests to a test or production portal

Can you potentially log the raw request body you're sending to the HubSpot API (minus the actual hapikey) so that we can take a closer look? Additionally, can you confirm the Hub ID of the account you're using?

4 Replies 4
Community Manager

Hey @dianacch ,

 

Are you including the proper authentication with your requests to the HubSpot API? Each request requires either an API key (included as a query parameter, like this: `&hapikey=xxxx`) or an access token (included in the `Authorization` header, like this: `Bearer xxxxxxx`). If you have some more details about the requests that are failing, please don't hesitate to post them here (without any sensitive authentication details) and we can help troubleshoot what's going on.

 

You can find some more details on authentication here: https://developers.hubspot.com/docs/methods/auth/oauth-overview

Occasional Contributor

@Derek_Gervais yes, i send the api key in the request:
https://api.hubapi.com/contacts/v1/contact/?hapikey=apikey

When i send a request from my localhost works fine but when my service is hosting in a host without certificate https doesn't works.

The certificate is the problem ? Is it necessary have a host with certificate https ?? 

 

Reply
0 Upvotes
Community Manager

Hi @dianacch ,

 

Apologies for the delay here. As far as I understand, it's not required that your client has an SSL certificate in order to make requests to the HubSpot API. This appears to be validated in this stack overflow article. That said, I'm not really clear on what exactly is happening here. A 401 with a hapikey almost always means one of two things:

  1. The request is being malformed in some way, so that the hapikey isn't being properly included
  2. The hapikey is a developer hapikey (from a developer account) and is used to make requests to a test or production portal

Can you potentially log the raw request body you're sending to the HubSpot API (minus the actual hapikey) so that we can take a closer look? Additionally, can you confirm the Hub ID of the account you're using?

Occasional Contributor

Thanks a lot @Derek_Gervais,  your post saved me.

The problem was in the host configuration hahahaha