How do I build an end point for an Ajax call in HubSpot COS?
Hello,
Can’t figure out how to build an endpoint for my AJAX in the HubSpot COS… any suggestions appreciated.
Here’s what I’ve done:
Created a new app with a HTML/JavaScript Quiz which is used in our HubSpot COS site.
When the visitor completes the the quiz the data is pushed to custom properties in their contact record (if they complete the form to become a contact).
Everything was working fine using the HubSpot API Keys (it’s only for our site).
When the site went live last night (using https) all the API Calls fail with the following error:
From research online I need to build an endpoint for the AJAX call… the problem is I haven’t been able to figure out how to create an endpoint inside the HubSpot COS.
Any help appreciated.
Thank you
Mike
p.s. posted as a new question just in case it’s useful for someone else.
How do I build an end point for an Ajax call in HubSpot COS?
@Webalite is the app you created hosted on HubSpot or somewhere else? Where is the Quiz? You don’t have server-side access on HubSpot to create an endpoint. The error you received is because you made a cross-domain request to our servers. Those requests need to be made server-side and not client-side.
How do I build an end point for an Ajax call in HubSpot COS?
Good morning Peter
The Quiz is client side only (JavaScript/JQuery) and is loaded on the homepage in my (entirely) HubSpot COS site.
Some of the more complex operations (for version 2) will require more intensive API calls (e.g. Timeline). Some of the API calls are unavailable unavailable in the templates through HubL.
Really keen for suggestions on how I’d call the API if my entire site is in the HubSpot COS?
I can set up another server to handle the Ajax queries but it seems – in my opinion – to defeat the purpose of using HubSpot COS. Trying to do things the proper way (no hacks) because there’s a few HubSpot Apps in my head that I need to code… so getting “My First App” right is a good test.
How do I build an end point for an Ajax call in HubSpot COS?
@Webalite To hit certain endpoints that are not in the Contact API like the Timeline for ex. This will have to be done using server-side code so you will have to use your second option of spinning up a server to handle the AJAX calls and then forward it along back to HubSpot. I agree this isn’t what I would call ideal but at the moment the COS does not have the ability to make server-side requests.