APIs & Integrations

SATXbassplayer
Member

Can't Create/Update Contact Record via API

I;m trying to figure out what I am doing wrong… any help would be appreciated!!


var eMail = "moe@stooges.com";
var fName = “Moe”;
var lName = “Howard”;
var hKey = “aoijfarfrsgrsgalsdjfop312u526134w5u13”; // junk - i tried demo as well
var hubspotURL = “https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/” + eMail + “/?hapikey=” + hKey;
var subj = {
“properties”: [
{“property”: “email”, “value”: eMail},
{“property”: “firstname”, “value”: fName},
{“property”: “lastname”, “value”: lName}
]};
var myJSON = JSON.stringify(subj);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function()
{
alert(this.readyState + " : " + this.status + " : " + this.statusText); // debugging
if (this.readyState == 4 && this.status != 200)
{
alert("Failure Response Text: " + this.responseText); // debugging
}
if (this.readyState == 4 && this.status == 200)
{
alert("Success Response Text: " + this.responseText); … debugging
}
};
xhttp.open(“POST”, hubspotURL, true);
xhttp.setRequestHeader(“Content-Type”, “application/json”);
xhttp.send(myJSON);

0 Upvotes
3 Replies 3
3PETE
HubSpot Employee
HubSpot Employee

Can't Create/Update Contact Record via API

@SATXbassplayer What is the response from HubSpot? Where are you making this request? Is this a Client-Side request?

0 Upvotes
SATXbassplayer
Member

Can't Create/Update Contact Record via API

This is a script run in Google Tag manager to strip data from a form on a
non-Hubspot platform, and enter it into the Hubspot database.

Response from Hubspot:

  • Alert 1: Ready State = 1; Status = 0; Response Text =
  • Alert 2: Ready State = 4; Status = 0; Response Text =
  • Alert 3: Response Text =
0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Can't Create/Update Contact Record via API

We are still smoothing over the HubSpot Forms and Google Tag Manager experience. See this post here for some work around as we work things over.

0 Upvotes