API contact update with invalid vid should return a 404

contacts

#1

EDIT: I was wrong, the API does send 404 if you send something that really looks like a vid. See below for details.

There was a time when the API returned a 404 with some tomcat HTML in it when we tried to update an inexisting contact via the update contact endpoint.
But now it returns an HTTP 200 OK when it didn't work.
When it works, it returns an HTTP 204 no-content.

I guess at least it's different but it is misleading as we can think it all worked well.


#2

It seems to be the same for deals, except that deal update will always return a 200 (successful or not...)


#3

Hi @fonji,

Just to check, are you explicitly including the Content Type: application/json header? I believe this is related to a known issue with the way requests missing this header get processed. I'm working with the team on a resolution to that issue, but in the interim I believe explicitly including that header should resolve the issue.


#4

Hi @Derek_Gervais , thanks for your response.

Yes, sending the header does not change the response.
BUT in my tests, I was using a non-integer value for the vid (the goal being to write a test case for the ruby gem).
If I send an integer of an inexisting contact, it works as expected.
Sorry for bothering you, I found the answer while writing a test case to answer your message :sweat_smile:

Here's my old, wrong, test case:

$ curl -X POST -H 'Content-Type:application/json' --dump-header - "https://api.hubapi.com/contacts/v1/contact/vid/invalid-not-existing-blabla/profile?hapikey=demo" -d '{"properties": []}'
HTTP/2 200 
date: Fri, 20 Jul 2018 08:29:39 GMT
content-length: 0
set-cookie: __cfduid=d1568037d77156ec42e77958d8df0da971532075379; expires=Sat, 20-Jul-19 08:29:39 GMT; path=/; domain=.hubapi.com; HttpOnly
access-control-allow-credentials: false
x-trace: 2B3F461642A8BD2ABB22CBACEF4ECEDF38D04CA5C3000000000000000000
strict-transport-security: max-age=31536000; includeSubDomains; preload
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 43d40fb1af85a8cf-CDG

But if I use a correct vid format, I do get a 404:

$ curl -X POST -H 'Content-Type:application/json' --dump-header - "https://api.hubapi.com/contacts/v1/contact/vid/1/profile?hapikey=demo" -d '{"properties": []}'
HTTP/2 404 
date: Fri, 20 Jul 2018 08:31:27 GMT
content-type: application/json;charset=utf-8
set-cookie: __cfduid=d0a315f7a6872286a9e2a4c052813099e1532075487; expires=Sat, 20-Jul-19 08:31:27 GMT; path=/; domain=.hubapi.com; HttpOnly
access-control-allow-credentials: false
vary: Accept-Encoding
vary: Accept-Encoding
x-hubspot-notfound: true
x-trace: 2B970C62A842799012AD070EBE4C5BC90CBE4A9AAA000000000000000000
strict-transport-security: max-age=31536000; includeSubDomains; preload
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 43d41251c876a863-CDG

{"status":"error","message":"resource not found","correlationId":"ddd8352b-faf6-4f18-a7f7-3e543277972d","requestId":"51b20027fe5eea3692221ca8717b50b3"}