APIs & Integrations

skhan37
Member

Using httr POST with Hubspot API

I am having issues using Hubspot API with httr. Basically, I keep getting a 415 error when I submit my query.

Here is my code which corresponds to the API example...

library(httr)

api_key=Sys.getenv("HUBSPOT_API_KEY")
  
url=paste0("https://api.hubapi.com/crm/v3/objects/companies/search?hapikey=",api_key)
  
query_header ="Content-Type: application/json"

body_data= '{"city": "Cambridge","domain": "biglytics.net","industry": "Technology","name": "Test API Biglytics","phone": "(877) 929-0687","state": "Massachusetts"}'
  
POST(url,
     body=body_data,
     header=query_header,
     encode="raw",
     verbose())

This returns me a 415 error.

Here is the link to the examples if needed: https://developers.hubspot.com/docs/api/crm/companies

Pretty sure I am doing a silly mistake there, but can't figure it out.

Thanks in advance for your help.

0 Upvotes
1 Reply 1
dennisedson
HubSpot Product Team
HubSpot Product Team

Using httr POST with Hubspot API

@skhan37 

Did you get this figured out?

Your body_data does not seem to be formatted in a way the search endpoint would expect.

0 Upvotes