<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Accessing custom  object in Serverless function in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/623514#M28499</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/358383"&gt;@VJeganathan&lt;/a&gt;&amp;nbsp;i dont think so. if u not have more then 100 requests per seconds.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 06:11:48 GMT</pubDate>
    <dc:creator>SJaeger</dc:creator>
    <dc:date>2022-04-28T06:11:48Z</dc:date>
    <item>
      <title>Accessing custom  object in Serverless function</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/619610#M28409</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am having many custom objects and want to access the same in Serverless function. When I try to do like below this,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;await hubspotClient.crm.objects.basicApi&lt;BR /&gt;.getById("mycustomobject", 1234567, ["myproperty"])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am always getting error like " unable to access&amp;nbsp;basicApi of undefined". Can anyone hellp to provide solution to read custom objects in Serverless function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Same code is working fine in Custm code action&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 09:56:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/619610#M28409</guid>
      <dc:creator>VJeganathan</dc:creator>
      <dc:date>2022-04-21T09:56:24Z</dc:date>
    </item>
    <item>
      <title>Betreff: Accessing custom  object in Serverless function</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/619989#M28422</link>
      <description>&lt;P&gt;Hello, do you have a solution? Because on one project I had the same problem and fixed it by axios.get to the HubSpot api.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 19:01:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/619989#M28422</guid>
      <dc:creator>SJaeger</dc:creator>
      <dc:date>2022-04-21T19:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing custom  object in Serverless function</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/620464#M28439</link>
      <description>&lt;P&gt;According to the &lt;A href="https://developers.hubspot.com/docs/api/crm/crm-custom-objects" target="_blank" rel="noopener"&gt;docs&lt;/A&gt;&amp;nbsp;remove the "objects" from the call so:&lt;/P&gt;
&lt;P&gt;await hubspotClient.crm.basicApi.getById&lt;SPAN&gt;("mycustomobject", 1234567, ["myproperty"]);&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 14:08:25 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/620464#M28439</guid>
      <dc:creator>piersg</dc:creator>
      <dc:date>2022-04-22T14:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing custom  object in Serverless function</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/621375#M28457</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp;, It throws error&lt;/P&gt;&lt;P&gt;ERROR Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: Cannot read property 'getById' of undefined","reason":{"errorType":"TypeError","errorMessage":"Cannot read property 'getById' of undefined","stack":["TypeError: Cannot read property 'getById' of undefined"," at Object.exports.main (/var/task/file.js:15:49)"," at Runtime.exports.hubspot_handler [as handler] (/var/task/hubspotHandler.js:6:21)"," at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'getById' of undefined"," at process.&amp;lt;anonymous&amp;gt; (/var/runtime/index.js:35:15)"," at process.emit (events.js:314:20)"," at processPromiseRejections (internal/process/promises.js:209:33)"," at processTicksAndRejections (internal/process/task_queues.js:98:32)"]}&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 09:36:09 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/621375#M28457</guid>
      <dc:creator>VJeganathan</dc:creator>
      <dc:date>2022-04-25T09:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing custom  object in Serverless function</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/621379#M28458</link>
      <description>&lt;P&gt;hey,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;why u make it not easy testing/debugging with local nodemon? so u find faster the errors in serverless functions.&lt;/P&gt;
&lt;P&gt;create a local index.js file called index.js:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;const hubspot = require("@hubspot/api-client");
const API_KEY = 'xxx' // portal api key for testing
const hubspotClient = new hubspot.Client({ apiKey: API_KEY });
const headers = {
  "Content-Type": "application/json"
}

const BASE_URL = 'https://api.sandbox.smartrecruiters.com'


function sendResponse (message) {
  console.log(message)
}

async function serverless (params = {}) {
  const response = await hubspotClient.crm.objects.basicApi.getById("mycustomobject", id, ["myproperty"])
    return response

  sendResponse({
    response,
    statusCode: 200
  });
}

serverless({})&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;now on your local machine where the index.js is localed type: "npm i nodemon &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/63720"&gt;@hubspot&lt;/a&gt;/api-client"&lt;/P&gt;
&lt;P&gt;after nodemon is installed u can type "nodemon index.js". later u can copy/past this script to your functions folder easily&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;now u see a detailed error messages from hubspot client.&lt;/P&gt;
&lt;P&gt;i think your current code have some errors in initialize process of the hubspot client.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;update: with my example i have to update current hubspot client, because i have the old v2 not current v3&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 09:54:39 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/621379#M28458</guid>
      <dc:creator>SJaeger</dc:creator>
      <dc:date>2022-04-25T09:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing custom  object in Serverless function</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/622811#M28487</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/185694"&gt;@SJaeger&lt;/a&gt;&amp;nbsp;, After fixing my firewall problem it seems working fine.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I saw network call is triggering internally, will it create problem due to rate limit?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 09:38:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/622811#M28487</guid>
      <dc:creator>VJeganathan</dc:creator>
      <dc:date>2022-04-27T09:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing custom  object in Serverless function</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/623514#M28499</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/358383"&gt;@VJeganathan&lt;/a&gt;&amp;nbsp;i dont think so. if u not have more then 100 requests per seconds.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 06:11:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/623514#M28499</guid>
      <dc:creator>SJaeger</dc:creator>
      <dc:date>2022-04-28T06:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing custom  object in Serverless function</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/623545#M28502</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/185694"&gt;@SJaeger&lt;/a&gt;&amp;nbsp; It is working fine with the approach you have mentioned above (index.js working fine in nodemon env). But if I paste the code in Design manager and try to execute the endpoint via Postman it thorws error " Execution Time: 722msRuntime.UnhandledPromiseRejection: TypeError: Cannot read property 'basicApi' of undefined". Kindly help me&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 08:32:23 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Accessing-custom-object-in-Serverless-function/m-p/623545#M28502</guid>
      <dc:creator>VJeganathan</dc:creator>
      <dc:date>2022-04-28T08:32:23Z</dc:date>
    </item>
  </channel>
</rss>

