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