Trouble with HubSpot API integration in Power BI

Hey everyone,

I'm hitting a snag with my HubSpot API code in Power BI. It's weird because this code worked fine before, but now it's acting up. The issue seems to be in this part:

outputList = try if initReq[paging][next][after] = null then initData else gather(initData, apiUrl) otherwise error "Failed outputList"

Even though initReq[paging][next][after] has data, the function crashes. It says something about "results" not having paging data. I'm lost here.

My code is trying to fetch deal data from HubSpot, paginate through it, and combine it all. But it's not playing nice.

Any ideas on how to fix this? I'd really appreciate some help!

Thanks,
Alex

I’ve encountered similar issues with the HubSpot API in Power BI before. One thing that helped me was to double-check the API response structure. Sometimes, HubSpot updates their API, which can break existing code.

Try adding some debugging steps. Print out the contents of initReq and initData to see exactly what you’re getting back. It’s possible the ‘paging’ or ‘next’ keys aren’t where you expect them to be.

Also, make sure your API key hasn’t expired and that you have the correct permissions for the data you’re trying to access. I once spent hours debugging only to realize my API key had limited access.

If all else fails, you might need to restructure your code to handle cases where the paging data isn’t present. It’s a pain, but it’ll make your code more robust in the long run.

Good luck with your integration!

I’ve run into this exact problem before. The issue likely stems from changes in the HubSpot API response structure. To troubleshoot, I’d suggest breaking down your code and checking each step individually. Start by examining the raw API response to ensure the paging data is where you expect it to be.

One workaround I’ve found effective is to implement a try-catch block around the problematic section. This allows you to handle cases where the paging data is missing without crashing the entire function. Additionally, consider implementing a rate limiter to avoid hitting API request limits, which can sometimes cause unexpected behavior.

If the issue persists, you might need to reach out to HubSpot support. They can provide insights into any recent API changes that might be affecting your integration. Remember to always keep your Power BI and HubSpot API versions up to date to minimize compatibility issues.