Bad Request creating Ecommerce property mappings

When I submit a PUT request to set up property mapping I receive a 400 Bad Request. I’m using this url https://api.hubapi.com/extensions/ecomm/v1/settings?hapikey=56af5b68......&appId=397… Whatt is wrong with this request the body is

{
 "enabled": true,
 "importOnInstall": true,
 "productSyncSettings": {
 "properties": [
 {
 "propertyName": "product_name",
 "dataType": "STRING",
 "targetHubspotProperty": "productname"
 },
 {
 "propertyName": "imageUrl",
 "dataType": "AVATAR_IMAGE",
 "targetHubSpotProperty": "ip__ecomm_bridge__image_url"
 }
 ]
 },
 "dealSyncSettings": {
 "properties": [
 {
 "propertyName": "order_total",
 "dataType": "NUMBER",
 "targetHubspotProperty": "amount"
 },
 {
 "propertyName": "customer_id",
 "dataType": "STRING",
 "targetHubspotProperty": "hs_assoc__contact_ids"
 },
 {
 "propertyName": "purchase_date",
 "dataType": "DATETIME",
 "targetHubspotProperty": "closedate"
 },
 {
 "propertyName": "stage",
 "dataType": "STRING",
 "targetHubspotProperty": "dealstage"
 }
 ]
 },
 "lineItemSyncSettings": {
 "properties": [
 {
 "propertyName": "order_id",
 "dataType": "STRING",
 "targetHubspotProperty": "hs_assoc__deal_id"
 },
 {
 "propertyName": "product_id",
 "dataType": "STRING",
 "targetHubspotProperty": "hs_assoc__product_id"
 }
 ]
 },
 "contactSyncSettings": {
 "properties": [
 {
 "propertyName": "given_name",
 "dataType": "STRING",
 "targetHubspotProperty": "firstname"
 },
 {
 "propertyName": "family_name",
 "dataType": "STRING",
 "targetHubspotProperty": "lastname"
 },
 {
 "propertyName": "email",
 "dataType": "STRING",
 "targetHubspotProperty": "email"
 }
 ]
 }
}

Hi, @aemmi.

Apologies for the inconvenience.

The 400 error code I received cited something wrong with the:

{
 "propertyName": "imageUrl",
 "dataType": "AVATAR_IMAGE",
 "targetHubSpotProperty": "ip__ecomm_bridge__image_url"
}

mapping, but I couldn’t find any issues with it.

I ended up building the settings one group at a time and they should now be uploaded successfully. Can you confirm with this endpoint?

Thank you for responding

I was able to verify those setting, I removed the imageUrl that you indicated was an issue and tried again but received the same 400 Bad Request. We do have OAuth setup and use it for all our other API calls, should I even be using this extensions/ecomm/v1/settings endpoint. If I can’t get past the 400 Bad Request how would I make changes to the mappings?

Hi, @aemmi.

Sorry to hear that you encountered another 400 error.

I’m not sure exactly why you’re seeing that error, as I was able to successfully update your mappings and add this dummy mapping:

{ "propertyName": "fooBarUrl",
 "dataType": "AVATAR_IMAGE",
 "targetHubspotProperty": "ip__ecomm_bridge__image_url"
}

I have since removed this mapping, but could you share the full settings you are trying to upsert (assuming they are different than your initial post)?
Even though you use OAuth for all your other API requests, upserting settings must be done with your developer API key, per this documentation. This is because you editing the settings of your app and not data in an account which has installed your app.

Issac,

Thanks for the update, other than this api.hubapi.com/extensions/ecomm/v1/settings how else can I check the setting or update them. Is this only done through the API?

Hi, @aemmi.

Sorry we were typing at the same time!

Yes, those settings can only be retrieved and modified via the API — at this time, there is no UI for Ecommerce Bridge mappings.

Thank You I’m have trouble on my end using https so I have been using http, could this be my issue?

Hey, @aemmi.

That could be part of the issue, however I was just able to add and remove another dummy contact property mapping using http://api.hubapi.com/extensions/ecomm/v1/settings?hapikey=your_developer_api_key&appId=your_app_id.

If you share the full set of mappings you’re trying to upsert, I’d like to try again myself.

Issac,

I believe I know what was causing my Bad Request. In my headers I had a nullvalue for Content-Length. I corrected that and now I’m receiving {“message”:“Value from portalId does not match hub-id implied by authorization used: 3977210 (oauth) vs 4445704 (portalId)”,“correlationId”:“202f9d86-bfdc-4f33-94a2-d5355e54fd3b”,“requestId”:“2fe5c8789c482412f5179b5a1a658459”} error.

My url is http://api.hubapi.com/extensions/ecomm/v1/settings?hapikey=56af5b68-xxx&appId=145xxx

Can you determine what isn’t setup properly

Issac,

Update I was able to process a successful mappings setting. I removed the Authorization’,'Bearer from the header. I thought I had to include this since we do use OAuth for our transactional emails. Is this not the case?

Apologies for the delayed response, @aemmi. I’m glad to hear you got this working!

The Upsert and Get ecommerce settings endpoints are a bit special. As I mention above:

Even though you use OAuth for all your other API requests, upserting settings must be done with your developer API key, per this documentation. This is because you editing the settings of your app and not data in an account which has installed your app.

Said differently, HubSpot wouldn’t recognize the OAuth token for one particular account (Hub ID) because you are trying to change the settings of your app across all accounts.

Thus, you should never have to use both an OAuth token and your developer API key. You will only ever use one or the other. In this case, the endpoints only accept your developer API key.

Thank You Issac,

I’m attempting to sync messages to this end point http://api.hubapi.com/extensions/ecomm/v1/sync-messages/PRODUCT and the attached code trying the developer HPIKEY , the app APIKEY or the OAuth and each time I receive this response {“message”:“This OAuth token (CM7nyu…) has not authorized the required scopes to complete this action, requires all of the following: [integration-sync]. Visit Working with OAuth - HubSpot docs for more information.”,“correlationId”:“22a72400-d9ef-484d-8f0b-9e14a2d3d41b”,“requestId”:“0c8664d9a684827dbf0cdfba0eb4d571”} even though I have intergration sync setup. Is there a step I need to do before this step. How is this step different than the import process

[{"integratorObjectId": "39","action": "UPSERT","changeOccurredTimestamp":153029475925,"propertyNameToValues": {"product_id": "39","product_name": "066-0811"} },{"integratorObjectId": "40","action": "UPSERT","changeOccurredTimestamp":153029475925,"propertyNameToValues": {"product_id": "40","product_name": "066-1117"}}]