# Error response for custom code action

**URL:** <https://community.hubspot.com/t/error-response-for-custom-code-action/128672>\
**Category:** APIs & Integrations\
**Tags:** workflows, developer-tools, professional\
**Created:** [March 26, 2025, 9:29am UTC](https://community.hubspot.com/t/error-response-for-custom-code-action/128672 "2025-03-26T09:29:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![IanShawUnily](https://avatars.discourse-cdn.com/v4/letter/i/9d8465/32.png) [@IanShawUnily](https://community.hubspot.com/u/IanShawUnily)\
**Post date:** [March 26, 2025, 9:29am UTC](https://community.hubspot.com/t/error-response-for-custom-code-action/128672/1 "2025-03-26T09:29:35Z")

</div>

Hi,

New to custom code actions, hoping I’m making a rookie error that someone can help with.

I’m trying to run the below as a custom code action in a workflow. It’s purpose is to get an authentication token that would then be used in another custom code action in the same workflow.

```lia-code-sample
const axios = require("axios");

const getAuthToken = async () => {
 const url = "https://auth.bizzabo.com/oauth/token";

 const data = {
 client_id: "<CLIENT_ID>", // Replace with actual Client ID
 client_secret: "<CLIENT_SECRET>", // Replace with actual Client Secret
 audience: "https://api.bizzabo.com/api",
 grant_type: "client_credentials",
 account_id: <ACCOUNT_ID> // Replace with actual Account ID
 };

 const headers = {
 "Content-Type": "application/json",
 };

 try {
 const response = await axios.post(url, data, { headers });
 console.log("Access Token:", response.data.access_token);
 return response.data;
 } catch (error) {
 console.error("Error:", error.response ? error.response.data : error.message);
 }
};

// Call the function
getAuthToken();

```

Client ID/Secret/Account ID all removed for obvious reasons.

When I run the equivalent cURL via postman it works fine, but in Hubspot I get this error:

`2025-03-26T09:13:26.446Z	ERROR	Invoke Error {"errorType":"TypeError","errorMessage":"customerPayload.main is not a function","stack":["TypeError: customerPayload.main is not a function"," at exports.hubspot_handler [as handler] (/var/task/hubspotHandler.js:7:21)"," at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)"]}`

Any idea where I’ve gone wrong?  
Thanks!

---

<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 26, 2025, 10:28pm UTC](https://community.hubspot.com/t/error-response-for-custom-code-action/128672/2 "2025-03-26T22:28:52Z")

</div>

Hey, @IanShawUnily👋 It sounds like your code can’t find the function `main`.

Have you tried adding something like:

```lia-code-sample
// Your code here...

// Add this at the end
exports.main = async (event, callback) => {
 try {
 const authData = await getAuthToken();
 callback({
 outputFields: {
 access_token: authData.access_token
 }
 });
 } catch (error) {
 callback({ error: error.message });
 }
};

```

Talk soon! — Jaycee
