Huspot API not working in production build/domain

contacts

#1

Hello,

I am making a server-side request (lambda function) using an hapikey to hubspot’s update contact property API endpoint.

The request works while running locally and in the development build on AWS S3, and returns {“status”: “success”, “response_data”: “{“vid”:******,“isNew”:false}”}.

However, when running on production and staging builds I am receiving {“status”: “success”, “response_data”: null} and the contact is not updating.

It seems to be an issue with domain or CORS, but I have set up cross-domain tracking to no avail.

Any help would be greatly appreciated.


#2

Hi @LukeP,

Could you give me a bit more info on the request you’re making? It sounds like you’re making a request to the contacts API. It’d be helpful to have the entire request and response you’re referring to. Additionally, since you mentioned CORS, it’s good to note that HubSpot does not support cross-origin (CORS) AJAX requests, since making the request client-side using JavaScript would expose any authentication you’re using for the request.


#3

The request is being made server-side with python so it’s likely not causing a CORS issue.

The company I’m working had already set up the configuration of calling the lambda functions so it’s unlikely that there is an issue there.

Here is the python request:

def putHubspotContact(data):
url = ‘https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/’ + data[‘email’] + '/'
params = {‘hapikey’: HS_API_KEY}
response = requests.post(url, data=json.dumps(data[‘payload’]), params=params)
print(response.url, json.dumps(data[‘payload’]), response.text )
return response.text

the request:

https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/email@domain.com/?hapikey=
{“properties”: [
{
“property”: “email”,
“value”: "email@domain.com"
},
{
“property”: “user_id”,
“value”: “auth0|hash”
},
{
“property”: “registration_status”,
“value”: “Registered and validated”
},
{
“property”: “email_verified”,
“value”: true
}
]}

the response:

Request URL:https://[omitted].amazonaws.com/staging/user/management
Request Method:POST
Status Code:200 OK
Remote Address:[omitted]
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Access-Control-Allow-Origin:*
Connection:keep-alive
Content-Length:44
Content-Type:application/json
Date:Tue, 03 Oct 2017 19:40:06 GMT
Via:1.1 5da521fbf2b6e4feeed8f179d3e6af3c.cloudfront.net (CloudFront)
X-Amz-Cf-Id:o5f5blBAjvcGM7jnj7eNpB9HfoQLso6vPiKR-mps9zFALFgVnyPV8Q==
x-amzn-RequestId:a8c10730-a872-11e7-a684-97c47dd57196
X-Amzn-Trace-Id:sampled=0;root=1-59d3e796-c2ef5ebc5ae53ca2d76e57db
X-Cache:Miss from cloudfront

Thanks for your help!