简体   繁体   中英

Connecting HubSpot to SQL Server over API

Pretty stumped at this point, hopefully someone has been able to figure out this problem before. I'm trying to create a process that will synchronize my user data from HubSpot and SQL Server (collected through my web app). This would involve me being able to write into HubSpot from SQL Server or vice versa. In order to do that I need to use their API and I'm having issues connecting to the API itself.

I was able to get the connection working with the Google OAuth 2.0 Playground and extract the customer data (so I know they work), but I want to create an equivalent connection R. From the research I've done so far, here's what I think may be the best options:

  1. Externally: I found a company called Zapier that apparently can do this if I pay for their services, I have never used them

  2. Inhouse: Using ROAuth or httr packages, but I couldn't authenticate successfully. I've tried:

     reqURL<- 'https://api.hubapi.com/contacts/v1/lists/all/contacts/all' accessURL<- "Couldn't figure out?" authURL<- 'https://app.hubspot.com/oauth/authorize?client_id=[my client id]&scope=contacts%20automation&redirect_uri=https://[mywebsite]' cKey<- 'my hubspot app client id' cSecret<- 'my hubspot app client secret' credentials<- OAuthFactory(consumerKey=cKey, consumerSecret=cSecret, requestURL=reqURL, accessURL=accessURL, authURL=authURL)

Also tried:

curl('https://api.hubapi.com/contacts/v1/lists/all/contacts/all/hapikey=[my hapi key]/get')

Helpful Links:

Fields:

I also have a Hapi key and App ID, but not sure if they're required

Really appreciate the help!

Cheers

After some digging, I was able to connect using the HAPI Key, rather than doing OAuth. It's actually pretty simple:

library(httr)
library(jsonlite)  

hs_data<- GET(paste("https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=",{yourapikey})
hs_data<- content(hs_data, as='text')
hs_data<- fromJSON(hs_data)
hs_data <- hs_data$contacts$properties

Some things that were messing me up previously:

  • Make sure to use your personal HAPI key, not the account (if you're admin) HAPI key
  • Make sure only Contacts scope is checked in your app, it doesn't work with more than 1 scope clicked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM