# batchAPI returns empty result in HubSpot

**URL:** <https://community.hubspot.com/t/batchapi-returns-empty-result-in-hubspot/125971>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [February 12, 2025, 6:42pm UTC](https://community.hubspot.com/t/batchapi-returns-empty-result-in-hubspot/125971 "2025-02-12T18:42:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SBasile](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sbasile/32/88586_2.png) [@SBasile](https://community.hubspot.com/u/SBasile)\
**Post date:** [February 12, 2025, 6:42pm UTC](https://community.hubspot.com/t/batchapi-returns-empty-result-in-hubspot/125971/1 "2025-02-12T18:42:03Z")

</div>

I’m testing HubSpot serverless functions. When properly formatted with an access key that has appropriate permissions and valid hs\_object\_ids, this code returns a result array of contact information when run from a local instance on a development machine. However, the same code returns a 200 status code with an empty result array when called from a serverless function in HubSpot. This code is almost identical to the example given in the HubSpot API documentation. Any ideas as to why would be appreciated.

```lia-code-sample
const hubspot = require('@hubspot/api-client');
exports.main = async (context, sendResponse) => {

const hubspotClient = new hubspot.Client({"accessToken": "access_key_here"});

const BatchReadInputSimplePublicObjectId = {propertiesWithHistory: ["firstname"], inputs: [{"id":"hs_object_id_here"},{"id":"hs_object_id_here"}], properties: ["email","firstname","lastname","phone"] };
const archived = false;

try {
 const apiResponse = await hubspotClient.crm.contacts.batchApi.read(BatchReadInputSimplePublicObjectId, archived);
 sendResponse({body: JSON.stringify(apiResponse.response.body, null, 2), statusCode: 200});
} catch (e) {
 e.message === 'HTTP request failed'
 ? console.error(JSON.stringify(e.response, null, 2))
 : console.error(e)
}

};

```

---

<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:** [February 13, 2025, 5:25pm UTC](https://community.hubspot.com/t/batchapi-returns-empty-result-in-hubspot/125971/2 "2025-02-13T17:25:02Z")

</div>

Hi, @SBasile 👋 Thanks for your question. I appreciate you including your details. I’d like to invite a few of our community experts to the conversation — hey @Kevin-C **@ChrisoKlepke @JBrake,** do you have any troubleshooting tips or suggestions for @SBasile?

Thank you very much for taking a look! — Jaycee

---

<div class="post-metadata">

**Author:** ![JBrake](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jbrake/32/76513_2.png) [@JBrake](https://community.hubspot.com/u/JBrake)\
**Post date:** [February 13, 2025, 6:52pm UTC](https://community.hubspot.com/t/batchapi-returns-empty-result-in-hubspot/125971/3 "2025-02-13T18:52:11Z")

</div>

This may be the security restriction mentioned here:  
[https://developers.hubspot.com/docs/reference/cms/hubl/functions#crm\_object](https://developers.hubspot.com/docs/reference/cms/hubl/functions#crm_object)  
(See **Please Note:** box).  
Jonathan.

---

<div class="post-metadata">

**Author:** ![SBasile](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sbasile/32/88586_2.png) [@SBasile](https://community.hubspot.com/u/SBasile)\
**Post date:** [February 13, 2025, 7:31pm UTC](https://community.hubspot.com/t/batchapi-returns-empty-result-in-hubspot/125971/4 "2025-02-13T19:31:20Z")

</div>

Hi Jonathan.

Thanks for your reply. If a understand you correctly, since a serverless function is a GET request is a public route you are suggesting that HubSpot is restricting access to the Contacts object? The strange thing is that I think I can use an can get access through an axios POST call in the same function which what I am trying as a workaround.

---

<div class="post-metadata">

**Author:** ![JBrake](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jbrake/32/76513_2.png) [@JBrake](https://community.hubspot.com/u/JBrake)\
**Post date:** [February 13, 2025, 7:37pm UTC](https://community.hubspot.com/t/batchapi-returns-empty-result-in-hubspot/125971/5 "2025-02-13T19:37:11Z")

</div>

Sorry, I only every POST to serveless functions so cannot offer any insight to that.

Jonathan

---

<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:** [March 6, 2025, 5:55pm UTC](https://community.hubspot.com/t/batchapi-returns-empty-result-in-hubspot/125971/6 "2025-03-06T17:55:11Z")

</div>

Hey, @JBrake 👋 I appreciate you taking the time to jump in. — Jaycee
