APIs & Integrations

ym42324
Participant

Products scope missing for private app (products API returns 500 error)

SOLVE

Hubspot account is 5664924.

 

My integration uses products API (https://api.hubapi.com/crm-objects/v1/objects/products/) to create ids associated with specific products, so they could then be added as line items to deal. Prior to this week, I was using API key authentication method and it worked great. However, this week I saw that API keys will be retired and switched to private app method. After that it stopped working. It simply returns me "Error 500 Request failed" error whenever I send a request to the URL.

 

The request I am trying to send:

url: https://api.hubapi.com/crm-objects/v1/objects/products/

http_headers:
Authorization: Bearer XXXXXXXXXXXXXXXXXXX
Content-Type: application/json

method: post

post data: [{"name":"name","value":"BUNWTBTWTN"},{"name":"description","value":"Universal Faux Stone Window and Door Trim"},{"name":"price","value":"33.0000"}]

 

Sample PHP code with private app (not working, gives 500 error):

$ch = curl_init('https://api.hubapi.com/crm-objects/v1/objects/products/');
curl_setopt($ch, CURLOPT_POSTFIELDS, '[{"name":"name","value":"BUNWTBTWTN"},{"name":"description","value":"Universal Faux Stone Window and Door Trim"},{"name":"price","value":"33.0000"}]');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer XXXXXXXXXXXXXXXXXXX', 'Content-Type: application/json') );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close ($ch);
var_dump($response);

 

Then a working example with hapikey:

$ch = curl_init('https://api.hubapi.com/crm-objects/v1/objects/products/?hapikey=YYYYYYYYYYYYYYYYYYYYYY');
curl_setopt($ch, CURLOPT_POSTFIELDS, '[{"name":"name","value":"BUNWTBTWTN"},{"name":"description","value":"Universal Faux Stone Window and Door Trim"},{"name":"price","value":"33.0000"}]');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json') );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close ($ch);
var_dump($response);

 

Upon digging into this, I noticed that within Scopes settings of private app there is no scope for "products" (it is simply missing) in all sections (CMS, CRM, Settings, Standard). Authorization header is correct and works for other scopes. So my asumption is that the error is due to missing scope.

 

But how do I communicate with products API then?

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Community Manager
Community Manager

Products scope missing for private app (products API returns 500 error)

SOLVE

Hey, @ym42324 👋 The required scope for the Product and Line Item APIs is:

“ecommerce”. This applies to both the v1 and v3 Create a Product endpoints.

product-v1.png

product-v3.png

I hope this helps you get moving forward! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

View solution in original post

0 Upvotes
3 Replies 3
Jaycee_Lewis
Solution
Community Manager
Community Manager

Products scope missing for private app (products API returns 500 error)

SOLVE

Hey, @ym42324 👋 The required scope for the Product and Line Item APIs is:

“ecommerce”. This applies to both the v1 and v3 Create a Product endpoints.

product-v1.png

product-v3.png

I hope this helps you get moving forward! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
ym42324
Participant

Products scope missing for private app (products API returns 500 error)

SOLVE

Thank you, Jaycee. After I enabled scope Standard/e-commerce, I am able to authorize and no longer getting the error message.

Jaycee_Lewis
Community Manager
Community Manager

Products scope missing for private app (products API returns 500 error)

SOLVE

Hey, @ym42324! Thanks for letting us know that worked for you 🙌 — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes