batchAPI returns empty result in HubSpot

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.

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)
}

};

Hi, @SBasile :waving_hand: 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

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

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.

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

Jonathan

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