List All Pages of Portal using Hubspot Page API


#1

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

#2

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: