<script language="javascript">
function SendPost(){
var xhttp = new XMLHttpRequest();
xhttp.onload = function() {
if (this.readyState == 4 && this.status == 200) {
var data = JSON.parse(this.response);
alert(this.responseText);
}
};
xhttp.open("POST", "https://api.hubapi.com/contacts/v1/lists?hapikey=xxxxxxxxx",true);
xhttp.setRequestHeader("Content-Type", "application/json");
var trinput = JSON.stringify({"name":"NEW LIST"});
xhttp.send(trinput);
}
</script>
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.hubapi.com/contacts/v1/lists?hapikey=9fb77290-e1af-42cd-8b20-ce7f32ff28cf. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Please do not share your HubSpot API publicly in these forums. This should never be exposed as it can be used to push and pull data from your portal. I've since removed it from your original post.
You mention you are trying to "Get a list with specific custom attribute values". Can you confirm if you want to "CREATE" a list of contacts or "GET" contacts in a specific list? The code you share is using the "Create a new contact list" endpoint. If that is the case then the following PHP code would work:
The output of the above would be a new list created with the name "HubSpot Email Addresses" with a filter to show all contacts who have an email that CONTAINS "@hubspot".
Please do not share your HubSpot API publicly in these forums. This should never be exposed as it can be used to push and pull data from your portal. I've since removed it from your original post.
You mention you are trying to "Get a list with specific custom attribute values". Can you confirm if you want to "CREATE" a list of contacts or "GET" contacts in a specific list? The code you share is using the "Create a new contact list" endpoint. If that is the case then the following PHP code would work:
The output of the above would be a new list created with the name "HubSpot Email Addresses" with a filter to show all contacts who have an email that CONTAINS "@hubspot".
Get Contacts from Specific Custom Attribute Value Query via HubSpot API
SOLVE
By using the above code we have successfully created a list using the standard property "Email" in the filter array as below: "filters" => array(array(array("operator" => "EQ", "value" => "monem.soliman@gmail.com", "property" => "Email", "type" => "string")))
But we got the error message "The remote server returned an error: (400) Bad Request", when we were using the custom property "Integrated" in filter array as below: "filters" => array(array(array("operator" => "EQ", "value" => "No", "property" => "Integrated", "type" => "string")))
Can you please ensure the internal name for the "Integrated" property is defined correctly. The property is case sensitive so if you pass through "Integrated" but the internal name is "integrated" it will return a 400 bad request.
I was successfully able to create a list in my own portal by using the below: