access denied when Upsert ecommerce settings

SOLVE
Resanehlab
Regular Contributor

Hi

 

I'm trying to create Ecommerce settings for my app through the Api. I followed this page https://developers.hubspot.com/docs/methods/ecommerce/v2/upsert-settings. The problem is, when I call this method with my developer api key and app id it returns this error: "Api[name=integrations-sync, subPath=/extensions/sync/v1/settings] Failed to process your request. Error code was '400'. Error message was:\nThis hub does not have write access for objectType[PRODUCT]".

 

What is wrong exactly and, what can I do with this? 

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Resanehlab
Solution
Regular Contributor

Finally, my problem solved. What a funny and ridiculous mistake was happening. I'm using Postman too. When I copied your request URL to the postman, it worked and, I realized that instead of "appId" parameter, I used the "appid" term. All of these problems happened because of the case-sensitive matter. I really appreciate your help. You saved my life. Thanks for your fantastic support.

 

Have a good day.

View solution in original post

Reply
0 Upvotes
7 Replies 7
IsaacTakushi
HubSpot Employee

Welcome, @Resanehlab.

 

That error message suggests the wrong API key was used. Can you confirm the following:

  1. The first five characters in the developer HAPIkey you used. (Please don't share the full key.)
  2. Your app ID.

Could you also share an example settings payload you are attempting to upload?

Isaac Takushi

Alumnus, HubSpot Developer Support
Reply
0 Upvotes
Resanehlab
Regular Contributor

Thanks for quick response. I'm using the 8da76 for hapikey and 196352 as appId. Below is the body of my request for upserting the settings.

 

{
"enabled":true,
"webhookUri":null,
"mappings":{
"CONTACT":{
"properties":[
{
"externalPropertyName":"DateOfBirth",
"hubspotPropertyName":"date_of_birth",
"dataType":"DATETIME"
},
{
"externalPropertyName":"Gender",
"hubspotPropertyName":"gender",
"dataType":"STRING"
},
{
"externalPropertyName":"FirstName",
"hubspotPropertyName":"firstname",
"dataType":"STRING"
},
{
"externalPropertyName":"LastName",
"hubspotPropertyName":"lastname",
"dataType":"STRING"
},
{
"externalPropertyName":"Email",
"hubspotPropertyName":"email",
"dataType":"STRING"
},
{
"externalPropertyName":"Phone",
"hubspotPropertyName":"phone",
"dataType":"STRING"
},
{
"externalPropertyName":"Fax",
"hubspotPropertyName":"fax",
"dataType":"STRING"
},
{
"externalPropertyName":"StreetAddress",
"hubspotPropertyName":"address",
"dataType":"STRING"
},
{
"externalPropertyName":"City",
"hubspotPropertyName":"city",
"dataType":"STRING"
},
{
"externalPropertyName":"StateProvince",
"hubspotPropertyName":"state",
"dataType":"STRING"
},
{
"externalPropertyName":"ZipPostalCode",
"hubspotPropertyName":"zip",
"dataType":"STRING"
},
{
"externalPropertyName":"Country",
"hubspotPropertyName":"country",
"dataType":"STRING"
},
{
"externalPropertyName":"CreatedOnUtc",
"hubspotPropertyName":"createdate",
"dataType":"DATETIME"
},
{
"externalPropertyName":"Company",
"hubspotPropertyName":"company",
"dataType":"STRING"
}
]
},
"DEAL":{
"properties":[
{
"externalPropertyName":"purchase_date",
"hubspotPropertyName":"closedate",
"dataType":"STRING"
},
{
"externalPropertyName":"name",
"hubspotPropertyName":"dealname",
"dataType":"STRING"
},
{
"externalPropertyName":"stage",
"hubspotPropertyName":"dealstage",
"dataType":"STRING"
},
{
"externalPropertyName":"abandoned_cart_url",
"hubspotPropertyName":"ip__ecomm_bride__abandoned_cart_url",
"dataType":"STRING"
}
]
},
"PRODUCT":{
"properties":[
{
"externalPropertyName":"product_description",
"hubspotPropertyName":"description",
"dataType":"STRING"
},
{
"externalPropertyName":"price",
"hubspotPropertyName":"price",
"dataType":"NUMBER"
},
{
"externalPropertyName":"product_name",
"hubspotPropertyName":"name",
"dataType":"STRING"
}
]
},
"LINE_ITEM":{
"properties":[
{
"externalPropertyName":"tax_amount",
"hubspotPropertyName":"tax",
"dataType":"NUMBER"
},
{
"externalPropertyName":"num_items",
"hubspotPropertyName":"quantity",
"dataType":"NUMBER"
},
{
"externalPropertyName":"price",
"hubspotPropertyName":"price",
"dataType":"NUMBER"
},
{
"externalPropertyName":"discount_amount",
"hubspotPropertyName":"discount",
"dataType":"NUMBER"
}
]
}
}
}

Reply
0 Upvotes
IsaacTakushi
HubSpot Employee

Hey, @Resanehlab.

 

Thanks for confirming.

 

It's strange — the API key, app ID, and payload all check out, and I was able to successfully upload the settings for you. Can you see them with this endpoint?

Isaac Takushi

Alumnus, HubSpot Developer Support
Reply
0 Upvotes
Resanehlab
Regular Contributor

Unfortunately, when I request to get settings, the 404 response is returned.

{
"status": "error",
"message": "No settings found - Have you defined any with https://developers.hubspot.com/docs/methods/ecommerce/v2/upsert-settings ?",
"correlationId": "778931aa-a9fa-49d6-9261-df0b4a99ad51",
"requestId": "2910e4f1a836dbd4b9e369533243f43a"
}

It's so strange to me also. I've been working on it in the past three days and, really can't understand what's going on.

Reply
0 Upvotes
IsaacTakushi
HubSpot Employee

Hey, @Resanehlab.

 

Interesting... Are you making these calls in your app or a REST client?

 

I'm using Postman and the following request URL is working for me (I've removed most of your developer HAPIkey):

 

GET https://api.hubapi.com/extensions/ecomm/v2/settings?hapikey=8da76...f4ea&appId=196352

 

The only header I'm using is Content Type: application/json.

 

Would you mind running the same test?

Isaac Takushi

Alumnus, HubSpot Developer Support
Reply
0 Upvotes
Resanehlab
Solution
Regular Contributor

Finally, my problem solved. What a funny and ridiculous mistake was happening. I'm using Postman too. When I copied your request URL to the postman, it worked and, I realized that instead of "appId" parameter, I used the "appid" term. All of these problems happened because of the case-sensitive matter. I really appreciate your help. You saved my life. Thanks for your fantastic support.

 

Have a good day.

View solution in original post

Reply
0 Upvotes
IsaacTakushi
HubSpot Employee

Hey, @Resanehlab.

 

I'm so glad to hear that! Haha, yes, our query parameters are case sensitive.

 

Happy to help. Have a great rest of your week!

Isaac Takushi

Alumnus, HubSpot Developer Support
Reply
0 Upvotes