APIs & Integrations

dhruvangensight
Member

List All Pages of Portal using Hubspot Page API

I’m Using Hubspot API in AJAX Request. But showing Following error in console

Response to preflight request doesn’t pass access control check: No ‘Access-
Control-Allow-Origin’ header is present on the requested resource.

This is running on same domain and portal.

My JS Code:

$(document).ready(function(){
    $.ajax({
        type:"GET",
        contentType: "application/json",
        url: "https://api.hubapi.com/content/api/v2/pages?hapikey=MYAPIKEY",
        success:function(data){       
            console.log(data);
        }
    });
})
0 Upvotes
1 Reply 1
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

List All Pages of Portal using Hubspot Page API

Hi @dhruvangensight,

The HubSpot APIs do not support support cross-origin (CORS) AJAX requests. Making the request client-side using JavaScript would expose any authentication you’re using for the request. You can find some more details here:

0 Upvotes