<?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: Custom Code workflow - Call External API in Data Hub</title>
    <link>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/689743#M997</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/371135"&gt;@Wakira&lt;/a&gt;&amp;nbsp;sounds like you need to see what the actual error is. Typically a "unhandled promise rejection" means you aren't handling a failed response. To do that you should be able to update your axios function to something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;axios
    .post(
      'www.APICarrier.com/api/tracking',
      requestBody,
      { headers: headers }
    )
    .then(response =&amp;gt; {
      console.log('Response from API: ${response.body}');
    }).catch(function (error) {
        if (error.response) {
          // Request made and server responded
          console.log(error.response.data);
          console.log(error.response.status);
          console.log(error.response.headers);
        } else if (error.request) {
          // The request was made but no response was received
          console.log(error.request);
        } else {
          // Something happened in setting up the request that triggered an Error
          console.log('Error', error.message);
        }
    });&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 06 Sep 2022 12:58:42 GMT</pubDate>
    <dc:creator>stefen</dc:creator>
    <dc:date>2022-09-06T12:58:42Z</dc:date>
    <item>
      <title>Custom Code workflow - Call External API</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/618361#M829</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try call a external api(third party) in mi workflow using custom code, but its not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this message:&lt;/P&gt;&lt;P&gt;"ERROR Unhandled Promise Rejection"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would it be possible to make an external call for this functionality?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 19:46:47 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/618361#M829</guid>
      <dc:creator>Wakira</dc:creator>
      <dc:date>2022-04-19T19:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Code workflow - Call External API</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/619135#M836</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/371135"&gt;@Wakira&lt;/a&gt;&amp;nbsp;could you please provide us with more details on your custom code without any private information? This way we will be able to investigate more about it and provide you with the next steps.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also like to invite our top experts&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/338029"&gt;@LMartinez7&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/152058"&gt;@bryce-corey&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/133"&gt;@stefen&lt;/a&gt;&amp;nbsp;any recommendations to&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/371135"&gt;@Wakira&lt;/a&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Pam&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 18:21:44 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/619135#M836</guid>
      <dc:creator>PamCotton</dc:creator>
      <dc:date>2022-04-20T18:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Code workflow - Call External API</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/619141#M837</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/60427"&gt;@PamCotton&lt;/a&gt;&amp;nbsp;, thanks for yout attention.&lt;BR /&gt;&lt;BR /&gt;The process is basically, we use a ticket as a control to monitor the delivery of one of our products, in this ticket there is a property that is the tracking code that needs to be consulted constantly in the carrier's api and update the ticket status property.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;I tried something similar to this (with changed values):&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;const axios = require('axios')

exports.main = (event, callback) =&amp;gt; {

  const headers = {
    'Authorization': 'Token 1234',
    'Content-Type': 'application/json'
  };

  const requestBody = {
    "data": {
     "df": 
    { "nf" : "11222",  
      "tpDocumento":1 
      }    
}
  }

  axios
    .post(
      'www.APICarrier.com/api/tracking',
      requestBody,
      { headers: headers }
    )
    .then(response =&amp;gt; {
      console.log('Response from API: ${response.body}');
    });
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 18:28:26 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/619141#M837</guid>
      <dc:creator>Wakira</dc:creator>
      <dc:date>2022-04-20T18:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Code workflow - Call External API</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/623722#M842</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/187447"&gt;@LMartinez&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/152058"&gt;@bryce-corey&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/133"&gt;@stefen&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/66933"&gt;@Pam&lt;/a&gt;&amp;nbsp;Do you have any guidance or help on how I can resolve this?&lt;BR /&gt;&lt;BR /&gt;thanks&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 13:34:39 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/623722#M842</guid>
      <dc:creator>Wakira</dc:creator>
      <dc:date>2022-04-28T13:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Code workflow - Call External API</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/689281#M994</link>
      <description>&lt;P&gt;Deal&amp;nbsp; assiciated with company andcompany associated with contact then company contact should associate with deal how I can do this with custom code in workflows&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/371135"&gt;@Wakira&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/133"&gt;@stefen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 08:34:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/689281#M994</guid>
      <dc:creator>RVerma4</dc:creator>
      <dc:date>2022-09-05T08:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Code workflow - Call External API</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/689743#M997</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/371135"&gt;@Wakira&lt;/a&gt;&amp;nbsp;sounds like you need to see what the actual error is. Typically a "unhandled promise rejection" means you aren't handling a failed response. To do that you should be able to update your axios function to something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;axios
    .post(
      'www.APICarrier.com/api/tracking',
      requestBody,
      { headers: headers }
    )
    .then(response =&amp;gt; {
      console.log('Response from API: ${response.body}');
    }).catch(function (error) {
        if (error.response) {
          // Request made and server responded
          console.log(error.response.data);
          console.log(error.response.status);
          console.log(error.response.headers);
        } else if (error.request) {
          // The request was made but no response was received
          console.log(error.request);
        } else {
          // Something happened in setting up the request that triggered an Error
          console.log('Error', error.message);
        }
    });&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 06 Sep 2022 12:58:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-Call-External-API/m-p/689743#M997</guid>
      <dc:creator>stefen</dc:creator>
      <dc:date>2022-09-06T12:58:42Z</dc:date>
    </item>
  </channel>
</rss>

