Can't Create/Update Contact Record via API

contacts

#1

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);


#2

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


#3

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 =

#4

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.