APIs & Integrations

nanderson
Membre

Some fields aren't updated when sending an UPSERT

When I send some sync messages to the API, the contact or deal is created/updated, but certain fields stay empty even if I'm sending what I believe are the correct properties. For example, I send this to the API:

PUT https://api.hubapi.com/extensions/ecomm/v2/sync/messages?hapikey=blah
{
  "storeId": "test-store",
  "objectType": "CONTACT",
  "messages": [
    {
      "action": "UPSERT",
      "externalObjectId": "bob.smith@example.com",
      "properties": {
        "firstname": "Bob",
        "lastname": "Smith",
        "customer_email": "bob.smith@example.com",
        "school_name": "",
        "phone_number": "1234567890",
        "address": "1234 Cherry Lane",
        "city": "Columbus",
        "state": "OH",
        "zip": "43212",
        "country": "US",
        "ip__ecomm_bridge__ecomm_synced": "true",
        "ip__ecomm_bridge__source_store_id": "test-store"
      }
    }
  ]
}

I get a 204 No Content in reply, I check the sync status and it says no errors. I check the contact, and some fields are changed, but firstname, lastname and the address fields (address, city, state, zip, country) are still empty on the contact. I checked the object properties and mappings, and I think those are the correct properties, but they still don't work.

Another example:

PUT https://api.hubapi.com/extensions/ecomm/v2/sync/messages?hapikey=blah
{
  "storeId": "test-store",
  "objectType": "DEAL",
  "messages": [
    {
      "action": "UPSERT",
      "externalObjectId": "237622",
      "properties": {
        "name": "237622",
        "purchase_date": 1573768786000,
        "dealtype": "order",
        "stage": "checkout_completed",
        "amount": 64.5,
        "ip__ecomm_bridge__ecomm_synced": "true",
        "ip__ecomm_bridge__source_store_id": "test-store"
      },
      "associations": {
        "CONTACT": [
          "bob.smith@example.com"
        ]
      }
    }
  ]
}

On the deal, dealtype and amount don't work. Again, I've checked all the things I could think of that I might be doing wrong, but it seems right and still doesn't work.

0 Votes
12 Réponses
Derek_Gervais
Ancien salarié HubSpot
Ancien salarié HubSpot

Some fields aren't updated when sending an UPSERT

Hey @nanderson ,

 

Can you post your property mappings? It sounds like mappings might be missing/misconfigured for some of those properties. On a cursory look, `firstname` and `lastname` are the internal property name of the default "First name" and "Last name" properties. However sending sync messages that include internal HubSpot property names directly isn't supported; you still need to create a mapping for those properties.

0 Votes
nanderson
Membre

Some fields aren't updated when sending an UPSERT

@Derek_Gervais That was a big part of the problem, thank you! I thought that the mappings were just for convenience, I didn't realize they were required. Once I added those, everything worked except for address, city, state, zip and country on the contact.

 

My mappings for those are below: 

"CONTACT": {
      "properties": [
        {
          "externalPropertyName": "city",
          "hubspotPropertyName": "city",
          "dataType": "STRING"
        },
        {
          "externalPropertyName": "school_name",
          "hubspotPropertyName": "company",
          "dataType": "STRING"
        },
        {
          "externalPropertyName": "customer_email",
          "hubspotPropertyName": "email",
          "dataType": "STRING"
        },
        {
          "externalPropertyName": "state",
          "hubspotPropertyName": "state",
          "dataType": "STRING"
        },
        {
          "externalPropertyName": "first_name",
          "hubspotPropertyName": "firstname",
          "dataType": "STRING"
        },
        {
          "externalPropertyName": "country",
          "hubspotPropertyName": "country",
          "dataType": "STRING"
        },
        {
          "externalPropertyName": "phone_number",
          "hubspotPropertyName": "phone",
          "dataType": "STRING"
        },
        {
          "externalPropertyName": "name",
          "hubspotPropertyName": "customer_name",
          "dataType": "STRING"
        },
        {
          "externalPropertyName": "last_name",
          "hubspotPropertyName": "lastname",
          "dataType": "STRING"
        },
        {
          "externalPropertyName": "postal",
          "hubspotPropertyName": "zip",
          "dataType": "STRING"
        },
        {
          "externalPropertyName": "street",
          "hubspotPropertyName": "address",
          "dataType": "STRING"
        }
      ]
    }

I tried changing the mappings to have the external name be different from the internal name, in case that was a problem, so I'm now sending something like this for the mapping above:

{
  "storeId": "test-store",
  "objectType": "CONTACT",
  "messages": [
    {
      "action": "UPSERT",
      "externalObjectId": "bob.smith@example.com",
      "properties": {
        "first_name": "Bob",
        "last_name": "Smith",
        "customer_email": "bob.smith@example.com",
        "school_name": "",
        "phone_number": "5311234567",
        "street": "65 S Front St",
        "city": "Columbus",
        "state": "OH",
        "postal": "43215",
        "country": "US",
        "ip__ecomm_bridge__ecomm_synced": "true",
        "ip__ecomm_bridge__source_store_id": "stenhouse-test-store"
      }
    }
  ]
}

I also tried both real and fake addresses, in case it was verifying the address before inserting, but neitiher worked.

0 Votes
Derek_Gervais
Ancien salarié HubSpot
Ancien salarié HubSpot

Some fields aren't updated when sending an UPSERT

Hey @nanderson ,

 

Apologies for the delay here. If you're seeing issues with specific properties, my guess is that there's some more information we can glean from the sync errors. Can you give me the Hub ID of the portal(s) you're working in, and some example contacts that you're seeing issues with? I'm happy to help dig into these.

0 Votes
nanderson
Membre

Some fields aren't updated when sending an UPSERT

Hi @Derek_Gervais, if the Hub ID is the number in the profile menu, then it's 5618249. The contact I've been testing with is nick.anderson@highlights.com. I did try doing a GET on https://api.hubapi.com/extensions/ecomm/v2/sync/status/stenhouse-test-store/CONTACT/nick.anderson@hi... to see if there were any sync errors, but the errors array was always empty. 

0 Votes
Derek_Gervais
Ancien salarié HubSpot
Ancien salarié HubSpot

Some fields aren't updated when sending an UPSERT

Hey @nanderson ,

 

I really appreciate your patience here. I dug into the logs we have on our end, as well as your account's sync settings and the status of the object in question. I'm not seeing any particular issue in your configuration, but I am noticing two things:

  1. It looks like you're sending the value 'US' for the 'country' property, which is an enumeration, but the value you want is actually 'United States'. You can check out this sync error here: extensions/ecomm/v2/sync/status/stenhouse-test-store/CONTACT/nick.anderson@highlights.com
  2. The last sync message for that specific contact was sent a few weeks ago; this isn't an issue in and of itself, but it does make it a bit harder to dig in on my end. Could you send another sync message (identical to the one above) and see if it works? If it does, awesome! If not, I'll have a much more recent example to investigate.

 

Again, I really appreciate your patience here, and I'm looking forward to getting to the bottom of this so that you can get up and running with the Ecommerce Bridge API!

0 Votes
nanderson
Membre

Some fields aren't updated when sending an UPSERT

@Derek_Gervais  The country was the last piece! Changing the country from US to United States fixed all of the address fields. Thanks for working with me on this.

 

The thing that I don't understand is why I didn't see the sync error. I was checking the sync status at the url that you had in #1 before you mentioned it, and the errors array was empty. When you said you saw the sync error, I refreshed that same URL, and then I saw the sync error about the country. Any idea why I didn't see the error before and I do now?

0 Votes
Derek_Gervais
Ancien salarié HubSpot
Ancien salarié HubSpot

Some fields aren't updated when sending an UPSERT

Hey @nanderson ,

 

I'm glad to hear it's up and running! Regarding the sync error; it's tough to say for certain, since the sync message (and the corresponding error) are pretty old. But the Ecommerce Bridge API is asynchronous, so it's possible that there was a delay between when the sync happened, and when it appears in the "Check sync status of an object" endpoint.

 

If you run into this issue again, please don't hesitate to post here again!

0 Votes
Mike_Eastwood
Conseiller clé | Partenaire solutions Gold
Conseiller clé | Partenaire solutions Gold

Some fields aren't updated when sending an UPSERT

Hi @nanderson 

 

Have you tried your code with an OAuth setp?

 

While the HAPI Key should work it's only used for testing and *not* production code.

 

I've had issues before where the HAPI Key didn't work... although I'd expect an error other than 204.

 

Have fun

Mike

nanderson
Membre

Some fields aren't updated when sending an UPSERT

Hi @Mike_Eastwood, no I didn't try OAuth. The Ecommerce Bridge Overview page says that "Note: When developing a custom solution for an individual HubSpot account, the OAuth token can be omitted and the API key for that account should be used instead." I'm doing this for an individiual Hubspot account, so it seems that the HAPI key is the way to go. The developers.hubspot.com page also says that the HAPI key should be used for custom solutions for a specific business.

 

I might have to end up trying OAuth, but I don't want to make that the first option. Thanks for replying though!

0 Votes
Mike_Eastwood
Conseiller clé | Partenaire solutions Gold
Conseiller clé | Partenaire solutions Gold

Some fields aren't updated when sending an UPSERT

Hi @nanderson 

 

If HubSpot says the API Token works it *should* work.

 

Do you use Postman for Testing? Postman will help you simulate the API Call and give you more transparency over any errors.

 

Have fun

Mike

0 Votes
nanderson
Membre

Some fields aren't updated when sending an UPSERT

@Mike_Eastwood I have a similiar tool, yeah. I get a 204 No Content response from the API, which seems to be what's expected. And then when I check the sync status of the object, it indicates that there are no errors. But when I look at the First Name and Last Name fields on the contact, there's nothing there.

0 Votes
Mike_Eastwood
Conseiller clé | Partenaire solutions Gold
Conseiller clé | Partenaire solutions Gold

Some fields aren't updated when sending an UPSERT

Hey @nanderson 

 

I would check the nesting of the data in your arrays/objects.

 

I have had issues before where I was mistakenly 1 level too deep (or too shallow) with my nesting so it would update the data as null.

 

Hard to explain but worht checking.

Mike

0 Votes