# HTTP request failed

**URL:** <https://community.hubspot.com/t/http-request-failed/89108>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [September 6, 2023, 7:23pm UTC](https://community.hubspot.com/t/http-request-failed/89108 "2023-09-06T19:23:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![igeorge5](https://avatars.discourse-cdn.com/v4/letter/i/45deac/32.png) [@igeorge5](https://community.hubspot.com/u/igeorge5)\
**Post date:** [September 6, 2023, 7:23pm UTC](https://community.hubspot.com/t/http-request-failed/89108/1 "2023-09-06T19:23:41Z")

</div>

Hi, everyone, I have the next endpoint in mi function:

```lia-code-sample
const hubspot = require('@hubspot/api-client');

exports.main = (context = {}, callback) => {
 // instantiate HubSpot node API client

 const hsClient = new hubspot.Client({ accessToken: "NOPE" });

 // Look up contact from the API
 return hsClient.crm.contacts.basicApi
 .getById(1460601)
 .then(resp => {
 // Pass the contact properties back
 callback({ results: resp.properties, body:resp });
 }) 
 .catch ((err) => {
 // Handle API call error
 console.error(err);
 // Option 1: Return no result
 callback({ results: null });
 // Option 2: Rethrow the error, which will result in an ERROR status for the function call
 throw err;
 });
};

```

is a simple call to crm contacts, to get a contact by id.

But I get the error:

UNHANDLED\_ERROR - Execution Time: 880msRuntime.UnhandledPromiseRejection: HttpError: HTTP request failed

I’ve looking the trouble, but I don’t what is the ploblem. I hope you can help me, thank you.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [September 7, 2023, 9:14pm UTC](https://community.hubspot.com/t/http-request-failed/89108/2 "2023-09-07T21:14:18Z")

</div>

Hi, @igeorge5 👋 To be safe you should rotate your Private App token ASAP as you exposed it in your original post. I removed it for you.

One suggestion on error handling to help you understand what might be happening:

- Can you update your error handling to print out the entire error? You can also add more context. This will be useful in troubleshooting.

Other culprits can be — scope, rate limits, or network issues. I acknowledge these are guesses, until confirmed. The error you shared doesn’t include enough detail to narrow it down further.

Best,

Jaycee
