Don't post my blog using hapikey. my key is not developer

getcontantlab
Member

$arr = array(
'properties' => array(
array(
'name' => 'My first API blog post!',
'post_body' => '<p>good testing for the main thing</p>'
)
)
);
$post_json = json_encode($arr);
$hapikey = 'my hapikey id';
$endpoint = 'https://api.hubapi.com/content/api/v2/blog-posts?hapikey=' . $hapikey;
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json);
@curl_setopt($ch, CURLOPT_URL, $endpoint);
@curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = @curl_exec($ch);
$status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_errors = curl_error($ch);
@curl_close($ch);
echo "curl Errors: " . $curl_errors;
echo "\nStatus code: " . $status_code;
echo "\nResponse: " . $response;

 

output is below:- 

curl Errors: Status code: 403 Response: {"correlationId":"08e80949-4eeb-4f00-b6cd-f1df0da55f24","message":"This hapikey (my hapikey) does not have proper permissions! (requires any of [content-access])","requestId":"f2e1bb0b-98dc-4606-ae03-55e5aa2327ae","status":"error"}

0 Upvotes
5 Replies 5
vrneuman
HubSpot Employee

Hi @getcontantlab,

 

The 403 error you're seeing here most commonly appears if you don't have access to the tool you're trying to use the API for.  Does the portal you're using have access to blog tools?  If not, then this request will always return an error.  

0 Upvotes
getcontantlab
Member

Thanks for the reply. But how to check? I have access or not for the blog posting through API. I am new to HubSpot.

0 Upvotes
vrneuman
HubSpot Employee

Hi @getcontantlab,

 

Whether you have access to blog posting via API depends on whether you can post to blogs using the in-app interface.  If you go to your navigation and can select Marketing > Website > Blog, you have blog access.  If any part of this path is locked or unavailable, you don't have blog access, which means that you can't post a blog post via API either.  

0 Upvotes
getcontantlab
Member

Thank you for replying.

But, I don't see the website option in Marketing menu. Please see the below screenshot.

I have not purchased the membership. They don't give access to post through API is it right?screenshot-app.hubspot.com-2019.07.11-11-16-59 (1).png

0 Upvotes
vrneuman
HubSpot Employee

Hi @getcontantlab ,

 

The fact that Website isn't showing up in your menu means that you don't have access to any of our web-hosting features, which includes blogs.  You can only do via API what you can do within your account itself.  Because you don't have a paid account, you can't host blogs on HubSpot, and thus can't post to a blog via API.  

 

For a full overview of the features available at different tiers (including Free), I recommend clicking See all features at the bottom of our Marketing Hub pricing page here: https://www.hubspot.com/pricing/marketing?edition=starter&term=monthly.

0 Upvotes