How to fix api key error?



When I tried to add the code

to my site laravel, I got an error

  1. Client error: GET https: // Hapikey = {{redacted}} & order_by = -publish_date & state = PUBLISHED & limit = 4result in a 401 Unauthorized` response:
    {“correlationId”: “3724c6e1-87b6-4f83-b12b-91f6658f71e6”, “message”: "This hapikey ({{redacted}}) h (truncated …)

  2. HTTP / 1.1 401 Unauthorized
    Access-Control-Allow-Credentials: false
    Content-Type: application / json; charset = UTF-8
    Content-Length: 206
    Date: Thu, 14 Dec 2017 12:23:22 GMT
    Connection: keep-alive

{“correlationId”: “3724c6e1-87b6-4f83-b12b-91f6658f71e6”, “message”: “This hapikey has been invalidated.”, “requestId”: “25ab0afcb522d4b391543673cf6b6987”, " status “:” error "}

After I removed the link error was not lost. What could be the problem?


Hi @Artem_Kolomoiets,

I’ve redacted the hapikey included in your post. Since this forum is publicly visible, it’s best practice to remove any authorization (hapikeys, OAuth tokens, etc) from your posts. Since this hapikey was visible for roughly a day, you might want to deactivate it and generate a new key.

Regarding your error; are you trying to make requests to the blog API on your site? The HubSpot APIs do not support support cross-origin (CORS) AJAX requests, since making the request client-side using JavaScript would expose any authentication you’re using for the request. In order to use JavaScript/AJAX, you would need to make the request (excluding any authentication) to an external server that could then add the needed authentication and make requests to HubSpot’s APIs server-side.