APIs & Integrations

artemida
Member

How to access the Products API to create products

SOLVE

Hello,
I am trying out the new Products API via the demo account. I am able to retrieve products, but not create them. This is my request :
POST https://api.hubapi.com/crm-objects/v1/objects/products?hapikey=demo
[
{
"name": "name",
"value": "test"
}
]

And this is the error response I get :
"Must have scope INBOUNDDB_PRODUCT_LIBRARY_WRITE"

0 Upvotes
1 Accepted solution
Derek_Gervais
Solution
HubSpot Alumni
HubSpot Alumni

How to access the Products API to create products

SOLVE

Hey @OliviaRafols ,

 

This thread is out of date. New test accounts created from the "Testing" dashboard of a Developer Account now include a Sales Professional trial by default. If the accounts you've listed do not currently have Sales Professional access, you should be able to click "Renew" from the "Testing" dashboard to update the accounts.

View solution in original post

79 Replies 79
Blokketjoin
Member

How to access the Products API to create products

SOLVE

Thank you for your kind guide and code. Yes, when I've added a super admin permissions for my website I still faced issues in some areas of my website page like Blooket hacks. Kindly please guide me more about it.

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to access the Products API to create products

SOLVE

The new OAuth documentation has been updated to reflect the fact that POST requests to the oauth/v1/token endpoint should have data in an x-www-form-urlencoded format:

 

grant_type=authorization_code&client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&client_secret=yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy&redirect_uri=https://www.example.com/&code=zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz

 

Thank you for bringing this to the team's attention, @pvavilin

Isaac Takushi

Associate Certification Manager
pvavilin
Member

How to access the Products API to create products

SOLVE

Thank you @IsaacTakushi  a lot. This legacy format works well.

IsaacTakushi
HubSpot Employee
HubSpot Employee

How to access the Products API to create products

SOLVE

Interesting. Our newer OAuth docs may be inaccurate here as I was able to replicate the error.

 

Can you try the data format shown in this legacy doc?

 

grant_type=authorization_code&client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&client_secret=yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy&redirect_uri=https://www.example.com/&code=zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz

 

Isaac Takushi

Associate Certification Manager
pvavilin
Member

How to access the Products API to create products

SOLVE

Hi!

Thank you, it was a typo. Anyway the request returns the same error

[pvavilin@hdp02 prophets]$ curl --request POST --url https://api.hubspot.com/oauth/v1/token --header 'Content-Type: application/x-www-form-urlencoded;charset=utf-8' --data '{"grant_type": "authorization_code", "client_id": "1252...", "client_secret": "b270...", "redirect_uri": "https://localhost", "code": "4c18..."}'
{"status":"BAD_GRANT_TYPE","message":"missing or unknown grant type","correlationId":"acf37022-ef58-4548-b00f-05b078208963"}
0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to access the Products API to create products

SOLVE

Hey, @pvavilin.

 

It looks like you included a comma (,) after the "grant-type" key instead of a colon (:) and are missing a comma after "redirect_uri": "https://localhost" and the "code" key.

The following should work:

curl --request POST --url https://api.hubspot.com/oauth/v1/token --header 'Content-Type: application/x-www-form-urlencoded;charset=utf-8' --data
'{"grant_type": "authorization_code", "client_id": "1252...", "client_secret": "b270...", "redirect_uri": "https://localhost", "code": "4c18..."}'

 

Isaac Takushi

Associate Certification Manager
0 Upvotes
pvavilin
Member

How to access the Products API to create products

SOLVE

Hi, @IsaacTakushi !

 

Thank you a lot for your answer. Yes, when I've added a super admin permissions for my account, I've finally got the Auth Code but now I see this error when I trry to obtain new access token:

 

[pvavilin@hdp02 ~]$ curl --request POST --url https://api.hubspot.com/oauth/v1/token --header 'Content-Type: application/x-www-form-urlencoded;charset=utf-8' --data '{"grant_type", "authorization_code", "client_id": "1252...", "client_secret": "b270...", "redirect_uri": "https://localhost" "code": "4c18..."}'
{"status":"BAD_GRANT_TYPE","message":"missing or unknown grant type","correlationId":"ee8f3e88-50e7-4810-bc42-ca62474190dd"}

Did I do something wrong or it is because an error you dig to with your team?

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to access the Products API to create products

SOLVE

Hi, @pvavilin.

 

Thanks for sharing that information.

 

There seems to be an issue on our side where your user still lacks some granular permissions to view unassigned custom object records and those owned by your team even though your user has permission to "view all" custom objects.

I was able to replicate this error in my own account. I will have to dig in a bit more with my team to resolve the matter. In the meantime, a super admin in your account will be able to successfully connect the app. Apologies for the inconvenience. I will be in touch once I better understand the cause.

Isaac Takushi

Associate Certification Manager
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to access the Products API to create products

SOLVE

Hi, @pvavilin.

 

Thank you for clarifying!

 

That error is expected for developer account 6908575. Apps cannot be installed in developer accounts since they lack the CRM, Marketing HubSales Hub, and Service Hub tools.

 

For the production account ending in 8110, it seems that your user does not have full custom object read permissions. If a super admin grants your user access to view all custom objects, you should be able to connect 209264 successfully. This permission toggle is located in SettingsUsers & Teams[User]ContactsCustom Object AccessView Everything.

 

Custom Object View Everything.jpg

If you are still unable to connect the app with this toggled on, please share an updated correlationId to help me troubleshoot further.

Isaac Takushi

Associate Certification Manager
0 Upvotes
pvavilin
Member

How to access the Products API to create products

SOLVE

Hi, Isaac! Thank you for your response.

 

We modified Custom Object Access but got the same error:

{"status":"USER_UNAUTHORIZED","message":"user does not have permissions to authorize scopes","correlationId":"8f8123cd-1ef0-45bf-9740-64ac6fb69643"}

 

0 Upvotes
pvavilin
Member

How to access the Products API to create products

SOLVE

Hi, @IsaacTakushi ! Yes, I'm using this account ending in 8110.

 

I'm trying to obtain new OAuth token but got following error: 

 

Couldn’t complete the connection

You don’t have permission to connect this integration. Learn more about integrations and user permissions.
 
The correlationId is 26055196-c4df-45a3-ad99-89253989166a
 
When I'm trying to obtain OAuth token using developer account 6908575 I'm getting following error:
 
Couldn’t complete the connection
This hub doesn't have access to some HubSpot features that are required by this integration. Please contact the integrator.
 
The correlationId is 47ac39f9-d230-43ff-ba7d-bcfdaf6d0329
0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to access the Products API to create products

SOLVE

Hi, @pvavilin.

 

Are you encountering this issue with the production account ending in 8110?

 

If so, I do see that your user has an assigned Sales Hub Professional seat but based on the number of scopes you have selected, several may be out of sync with your user's permissions. Did you receive a correlationId with the error? Can you share that with me and the day the error occurred?

Isaac Takushi

Associate Certification Manager
0 Upvotes
pvavilin
Member

How to access the Products API to create products

SOLVE

Hello! I still have this problem.

My Hub ID is 6908575

My Application ID is 209264

 

I'm trying to get products but am getting this error: Must have scope inbounddb-product-library-read.

When I'm trying to get line items I'm getting the error: Must have scope deal-line-item-read.

 

I'v added sales professional license to my account and tryied to re-generate OAuth token and have gotten the error that says that I have no permissions to obtain new token with these scopes:

 

scopes=contacts%20content%20reports%20social%20automation%20actions%20crm.import%20business-intelligence%20oauth%20e-commerce%20crm.schemas.custom.read%20crm.objects.custom.read

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to access the Products API to create products

SOLVE

Sorry I missed your post, @tejashviy.

Account 4686199 is a production account, not a test account. I will only grant Sales Pro access to developer test accounts.

If you have a developer test account to which you would like Sales Pro access added, let me know. Otherwise, you can talk to your account manager or HubSpot sales to upgrade to a Sales Hub Professional subscription.

Isaac Takushi

Associate Certification Manager
0 Upvotes
JoeyHaalboom
Participant

How to access the Products API to create products

SOLVE

Hey @IsaacTakushi @Derek_Gervais 

 

Im trying to get a list of all the products but I get an error response.
"status":"error","message":"Must have scope inbounddb-product-library-read"

It is for the portal: 6299272, and I am a Sales Professional

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to access the Products API to create products

SOLVE

Hey, @JoeyHaalboom.

 

I do see that your user has the proper in-app permissions.

 

Are you using an app's OAuth token? If so, could you share the app's ID?

 

The user who connected the app must have also had a Sales Professional seat when they completed the OAuth flow, otherwise the resulting token will not have the inbounddb-product-libarary-read scope.

Isaac Takushi

Associate Certification Manager
0 Upvotes
JoeyHaalboom
Participant

How to access the Products API to create products

SOLVE

Hi @IsaacTakushi 

 

This is the app id: 212990

I connected the app to my user account which is a SalesProfessional account.

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to access the Products API to create products

SOLVE

Hi, @JoeyHaalboom.

 

Thanks for clarifying.

 

App 212990 does not require the e-commerce scope, which grants access to the Products and Line Items APIs.

 

If you are trying to use the Get all products endpoint through this app, the integration-sync scope is not sufficient.

 

To resolve this behavior, mark the e-commerce scope as required in your app's auth settings and complete the OAuth flow again at the new auth URL with a Sales Hub Professional user. It is not necessary to uninstall the integration before reauthenticating.

Isaac Takushi

Associate Certification Manager
JoeyHaalboom
Participant

How to access the Products API to create products

SOLVE

Hi @IsaacTakushi 

 

That solves the problem. Thank you!

OliviaRafols
Participant

How to access the Products API to create products

SOLVE

Hey @Derek_Gervais and @IsaacTakushi . I hope you are having a good day. I would also like to request Sales Pro access to the following test portals: 5139869 and 5466092.

 

Thank you!

0 Upvotes