Chat message error

forms

#1

Hello
I will integrate the code of sending messages on my site and I have error file: //js.hs-scripts.com/4984323.js net :: ERR_FILE_NOT_FOUND after I took the code I modify them by creating a new file js and now I have this message in my console v2.js:12 Couldn't find target container #hbspt-form-1538847199826-342745802 for HubSpot Form b393b2de-0679-4bd6-b2af-5649e8145462. Not rendering form onto the page
it is the code in my new file js

(function (id, src) {
if (document.getElementById(id)) { return; }
var js = document.createElement('script');
js.src = src;
js.type = 'text/javascript';
js.id = id;
var e = document.getElementsByTagName('script')[0];
e.parentNode.insertBefore(js, e);
})('hs-analytics', 'https://js.hs-analytics.net/analytics/1538847000000/4984323.js');

(function (id, src, attrs) {
if (document.getElementById(id)) {
return;
}
var js = document.createElement('script');
js.src = src;
js.type = 'text/javascript';
js.id = id;
for (var name in attrs) { if(attrs.hasOwnProperty(name)) { js.setAttribute(name, attrs[name]); } }
var e = document.getElementsByTagName('script')[0];
e.parentNode.insertBefore(js, e);
})('hubspot-messages-loader', 'https://js.usemessages.com/conversations-embed.js', {"data-loader":"hs-scriptloader","data-hsjs-portal":4984323,"data-hsjs-env":"prod"});


#3

Hi @maven,

Could you clarify your goal? Are you looking to install HubSpot live chat on your site or add custom functionality?


#4

hi @Isaac_Takushi In reality I am in a project and the goal is to be able to recover a contact who are in the hubspot crm by his mail and add it to my base to give. I code with asp.net and to communicate with the hubspot lapi I use this javascript code may I still have this message No 'Access-Control-Allow-Origin'
var data = null;

                var xhr = new XMLHttpRequest();
                xhr.withCredentials = true;

                xhr.addEventListener("readystatechange", function () {
                if (this.readyState === 4) {
                    console.log(this.responseText);
                }
                });

                xhr.open("GET", "https://api.hubapi.com/contacts/v1/contact/email/xx@xx.com/profile?hapikey=xxxxxxxx");
                xhr.setRequestHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
                xhr.setRequestHeader("Access-Control-Allow-Origin","*");
                xhr.setRequestHeader("cache-control", "no-cache");
                xhr.setRequestHeader("postman-token", "dd9e49c7-9b9f-ca5a-0307-fadf13e91341");
              
               
                xhr.send(data);

#5

Hi @maven,

The Contacts API does not support CORS/AJAX requests. Per this article, only the v3 Forms API and HubDB APIs support this.

To GET a contact's email, you'll need to ping your server first, which can then add authentication and make the request to https://api.hubapi.com/contacts/v1/contact/email.