Contacts not updating from POST even with 202 accepted

contacts

#1

Hello.

I am doing a mass update of all my companies contacts using HTTP requests. I've written a program to GET 100 contacts, update their properties, and then POST those 100 contacts. I do this 100 contacts at a time for all 100,000+ contacts we have. For every post I get a 202 accepted status, but when I check HubSpot the properties are not updated.

I know the properties are correctly updating because I wrote all the contacts to a CSV and all the properties were as expected. A good example of this is the "Country" property for our contacts. Half of our contacts are missing a country, but have a "State" listed so I update the country based on state. In the CSV all of the contacts show that they now have a country, but in HubSpot when I filter the contacts by "Country: is known" the number doesn't change.

It gets weirder because if I delete the set country of a contact and run the script that contacts country will be properly set. So it just doesn't seem to be working on a massive scale. Any ideas as to what could be happening? Thanks


#2

@gkochmann can you show me an example of your call to HubSpot and the response of a contact that doesn't update?


#3

Here's what the JSON I am posting looks like except it has 100 contacts.

[
{
  "vid": "12345",
  "properties": [
    {
      "property": "country",
      "value": "United States"
    },
    {
      "property": "firstname",
      "value": "Joe"
    },
    {
      "property": "jobtitle",
      "value": "TBD"
    },
    {
      "property": "primary_role",
      "value": "Advisor"
    },
    {
      "property": "company",
      "value": "example"
    },
    {
      "property": "state",
      "value": "CA"
    },
    {
      "property": "email",
      "value": "example@email.com"
    },
    {
      "property": "lastname",
      "value": "Smith"
    }
  ]
},
{
  "vid": "12346",
  "properties": [
    {
      "property": "country",
      "value": "United States"
    },
    {
      "property": "firstname",
      "value": "Bob"
    },
    {
      "property": "jobtitle",
      "value": "TBD"
    },
    {
      "property": "primary_role",
      "value": "Advisor"
    },
    {
      "property": "company",
      "value": "example"
    },
    {
      "property": "state",
      "value": "CA"
    },
    {
      "property": "email",
      "value": "example@gmail.com"
    },
    {
      "property": "lastname",
      "value": "smith"
    }
  ]
}
]

See if I were to just post this one set of contacts it would work fine. It's when I am doing this rapidly for all 100,000+ contacts that they don't seem to update properly. Should I be waiting a certain amount of time between POSTs? Or do you have any thoughts as to why it doesn't work on a large scale. Like I mentioned the status of every call is 202 accepted.


#4

@gkochmann we do have limit of 10 calls per second. do you get any errors when they don't update properly?


#5

@pmanca no I don't see any errors when they don't update. Like I said I print out the status of every call and I get a 202 accepted. I tried sleeping the thread of my program and limiting it to one call per second and that didn't seem to do the trick. I've run out of ideas on why it is not working. If I run the same program on just the first 100 contacts it updates them just fine. It's only when I try to make many calls in a row that it starts to not update them properly.


#6

@gkochmann Seems like a tricky one. With out an example to dive into, it can be tough to troubleshoot. If there is any way you can get me an example of a contact that didn't update but returned a 202 I think that would be a good starting point for us. Does the whole batch fail or just 1 in the batch fail and the others succeed?


#7

Hi!
I have exactly same problem. I got 202 response but contacts are not updated. I changed json content string to bytecodes when sending data. Is it the right thing to do?


#8

here is my json:
"[
{
"Email":"testi282@hh.fi",
"Properties":[
{"Property":"firstname","Value":"testi"},{"Property":"lastname","Value":"keissi"}]}
,{"Email":"testi282@hh.fi",
"Properties":[{"Property":"firstname","Value":"testi"},{"Property":"lastname","Value":"keissi"}]},
{"Email":"testi282@hh.fi",
"Properties":[{"Property":"firstname","Value":"testi"},{"Property":"lastname","Value":"keissi"}]}
]"


#9

I have a trial version of HubSpot application for testing purposes. Could it be the reason? Is it not possible to add or update contacts in demo application?


#10

@Sari_Rautanen Having a trial shouldn't effect the outcome. Do you have an example of the response from hubspot and the network call you made to hubspot? It would be helpful to see the actual POST request you make to HubSpot.


#11

Here is the request and the response. I just took away the access token and the cookie from the response.

{Method: POST, RequestUri: 'https://api.hubapi.com/contacts/v1/contact/batch/', Version: 1.1, Content: System.Net.Http.ByteArrayContent, Headers:
{
Authorization: Bearer CLbkz...
x-ms-request-root-id: c77df477-40455941c789530b
x-ms-request-id: |c77df477-40455941c789530b.3.
Request-Id: |c77df477-40455941c789530b.3.1.
Content-Length: 373
Content-Type: application/json
}}

{StatusCode: 202, ReasonPhrase: 'Accepted', Version: 1.1, Content: System.Net.Http.NoWriteNoSeekStreamContent, Headers:
{
Connection: keep-alive
Date: Fri, 09 Mar 2018 17:57:55 GMT
Server: cloudflare
Set-Cookie: __cfduid=...; expires=Sat, 09-Mar-19 17:57:55 GMT; path=/; domain=.hubapi.com; HttpOnly
Vary: Accept-Encoding
Vary: Accept-Encoding
Access-Control-Allow-Credentials: false
X-Trace: 2B2DA27D31CDBA444C2B41E34647243D307A1F0609000000000000000000
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
CF-RAY: 3f8f6d3c19d05b5d-HEL
Content-Length: 0
}}


#12

I got this to work finally! I just had to change first capital letters to normal: Property -> property, Value -> value. You should respond with an error code if this kind of errors in request structure appears.


#13

@Sari_Rautanen I agree that should be a 4xx level error code. I will pass this along to our API team.