Create/Update a Contact record using API not working

SOLVE
Highlighted
New Member

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

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

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Community Manager

Hey @APGEconsultant I'd advise also posting this question here on HubSpot's API forum where our community of HubSpot developers and integration partners can help you out Smiley Happy

Reply
0 Upvotes
2 Replies 2
Community Manager

Hey @APGEconsultant I'd advise also posting this question here on HubSpot's API forum where our community of HubSpot developers and integration partners can help you out Smiley Happy

Reply
0 Upvotes
crm
New Contributor

Hello Team,

 

Greetings!

 

I am using API https://developers.hubspot.com/docs/methods/contacts/create_or_update

I am getting following response:-

405 Method Not Allowed

 

Can you please help me to resolve this issue?

 

Thanks & Regars,

Ajay

 

 

Reply
0 Upvotes