Azure Data Factory unable to retrieve data from HubSpot CRM despite valid authentication

I am attempting to extract contact records from HubSpot using Azure Data Factory and facing some challenges. I’ve created a private app in HubSpot and I’m trying to access this API endpoint:

https://api.hubapi.com/crm/v3/objects/contacts?Authorization=Bearer: pat-******&Accept=application/json

This endpoint works perfectly in Postman with OAuth authentication, returning the expected contact data. However, when I set up the REST linked service in Azure Data Factory, the connection test completes successfully, but the copy activity does not return any data.

I receive a 401 Unauthorized error message when previewing the data:

Rest call failed with client error, status code 401 Unauthorized
Request URL: https://api.hubapi.com/crm/v3/objects/Contacts
Response: {"status":"error","message":"Authentication credentials not found"}

I believed that using the REST API with a Bearer token would eliminate any need for extra authentication, but it seems there may be additional authorization steps I need to take. Has anyone managed to successfully extract data from HubSpot using Azure Data Factory? What should I do regarding authentication?

You’re passing the authorization header wrong in your REST linked service config. Don’t put ?Authorization=Bearer: pat-****** in the URL - that won’t work. Here’s how to fix it: Set your REST linked service authentication type to “Anonymous”, then add the Bearer token in Additional headers as Authorization: Bearer pat-****** (use a space after Bearer, not a colon). Or if your ADF version has it, just use the “Bearer token” authentication type directly. I’ve hit this same issue with other API integrations - the headers need to go in the linked service properties, not the URL. Also double-check that your HubSpot private app has the right scopes enabled for contact records.

I’ve faced a similar issue with Azure Data Factory and HubSpot integration. It’s crucial to ensure that you’re not only passing the Bearer token correctly but also managing its lifecycle. Sometimes, the tokens can expire, which leads to those 401 Unauthorized errors you’re seeing. To avoid running into this problem, I found it helpful to implement a token validation step before executing your copy activity. By making an initial call to check the token’s validity, you can gracefully handle any expiration issues ahead of time. Additionally, ensure your private app has the necessary scopes, specifically for accessing contact records, as lacking the correct permissions can further complicate your data retrieval.

check your endpoint url - you’ve got /crm/v3/objects/Contacts in the error but /crm/v3/objects/contacts in your working postman call. hubspot’s api is case sensitive, so that capital C is probably breaking it. also make sure your private app token has the crm.objects.contacts.read scope enabled.

Been there - Azure Data Factory is a nightmare for HubSpot REST API stuff. Token handling breaks constantly and you’re stuck debugging auth instead of building your pipeline.

I moved everything to Latenode and it’s way better. Just add your HubSpot creds once and it auto-handles OAuth refreshes. No more 401 errors or header headaches.

Best part? Visual setup. Connect HubSpot, add transforms, push data wherever. Mine runs hourly pulling contact updates - zero issues.

Error handling actually works too. When stuff breaks, you get real error messages instead of ADF’s cryptic garbage.