Skip to main content

I have created an event subscription that listen for when new entities are added to a tearsheet in Bullhorn. When I test the setup test data flows in and I am able to use the data but I am not able to publish my zap. I have the Zap turned on but when I add a entity to a tearsheet the zap does not trigger. Anyone know what I am doing wrong?

Bullhorn documentation: https://bullhorn.github.io/rest-api-docs/#events

Here is my Perform List code:

const options = {
  url: 'https://rest{swimlane#}.bullhornstaffing.com/rest-services/{corptoken}/event/subscription/tearsheetSub_2024?maxEvents=100',
  method: 'GET',
  headers: {
    'Accept': 'application/json',
  },
  params: {
    'BhRestToken': bundle.authData.BhRestToken
  },
  removeMissingValuesFrom: {
    'body': false,
    'params': false
  },
};

return z.request(options)
  .then((response) => {
    let results;
    try {
      results = response.json;
    } catch (e) {
      throw new Error('Failed to parse JSON response');
    }

    if (!results) {
      // No data found, not necessarily an error, just an empty response
      console.warn('No tearsheets could be found. The API response was empty or null.');
      return w]; // Return an empty array to indicate no data was found
    }

    if (Array.isArray(results.events)) {
      return results.events; // Return the array of events
    } else {
      throw new Error('Invalid API response: "events" is missing or not an array');
    }
  })
  .catch((error) => {
    console.error('Error retrieving tearsheets:', error.message);
    throw new Error(`Unable to pull tearsheets. Please reload the page. If the issue persists, troubleshoot the error or contact Support.\n\nError code: ${error.message}`);
  });

Zap Test:

 

 

Be the first to reply!

Reply