Access control error

forms
contacts

#1

hi i'm on a project and i get the contacts that are registered on my site which are local to submit them to my hubspot app and i have this message in my console
request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. this is the code i use
$.ajax({
type: "POST",
url: api,
crossDomain : true,
xhrFields: {
withCredentials: true
},
headers:{
"content-type":"json/application",
"Access-Control-Allow-Origin":"*",
"Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept"
},
data:data1
})
.done(function( data ) {
console.log("done");
})
.fail( function(xhr, textStatus, errorThrown) {
alert(xhr.responseText);
alert(textStatus);
});


#3

Hi @maven,

Which endpoint are you using?

As this documentation states, most of HubSpot's APIs do not support CORS AJAX requests. The only POST method which supports AJAX is for the Forms API.

If you are using the Forms API, please share an example request URL and body which failed.


#4

hi @Isaac_Takushi
thank you I solved it using the API forms


#5