Get the blog post for specific blog


#1

Hi,

We created 2 blogs called 'Insights' and 'News'.
Earlier we were using following API url to fetch all blog posts: https://api.hubapi.com/content/api/v2/blog-posts?hapikey=*****&limit=8&state=PUBLISHED

But now when we are trying to get list based on content_group_id for 'News' as following https://api.hubapi.com/content/api/v2/blog-posts?hapikey=*****&content_group_id=6750911255&limit=8&state=PUBLISHED

Its returning nothing.

Also I tried this https://api.hubapi.com/content/api/v2/blog-posts/6750911255?hapikey=*****&limit=8&state=PUBLISHED still its returning null.

Can you please suggest the correct query string for the url.

Thanks,
Sabita.


Get the blog posts for specific blog
#3

Hi, @Sabita_Sahoo.

Happy to help. Did you open this topic as well? Please refrain from creating multiple topics for the same question. The Developer Support Team strives to respond to queries within two working days, so we'll get to the oldest topic first.

Using the content_group_id parameter is correct, but I'd like to check the results you receive myself. What is your Hub ID?


#4

Hi Issac,

yes that topic was being created by our client. Yes we will not create multiple topics for same query in future.
Its ok you can respond here :slight_smile:

Our Hub ID : 2498754

Thanks


#5

Thank you for sharing the Hub ID, @Sabita_Sahoo.

I am able to successfully retrieve data for the "News" blog and its sole blog post at this time.

To pull the one blog post through this endpoint, I used:

https://api.hubapi.com/content/api/v2/blog-posts?content_group_id=6750911255&state=PUBLISHED&limit=8

But it also worked with:

https://api.hubapi.com/content/api/v2/blog-posts?content_group_id=6750911255&limit=8&state=PUBLISHED

and other variations I tried.

Here is some of the data returned:

{
limit:8,
objects:[
{
ab:false,
ab_variation:false,
absolute_url:"https://www.blog.rhapsodymedia.co.uk/company-news/tim-moscow-takes-up-the-reigns-at-rhapsody",
allowed_slug_conflict:false,
analytics_page_id:"5324287810",
analytics_page_type:"blog-post",
archived:false,
are_comments_allowed:true,
attached_stylesheets:[ ],
author:"sabina.[redacted]@rhapsodymedia.co.uk",
author_at:1544611978071 (December 12, 2018, 5:52:58am UTC-05:00),
author_email:"sabina.[redacted]@rhapsodymedia.co.uk",
author_name:"Sabina [Redacted]",
author_user_id:3810969,
author_username:"sabina.[redacted]@rhapsodymedia.co.uk",
...

I could also retrieve this single blog post via this endpoint using:

https://api.hubapi.com/content/api/v2/blog-posts/5324287810

The request URL you are using is correct, and there doesn't appear to be an issue with the endpoint, since I can retrieve the data successfully. Are you certain you are using the correct API key? For reference, it is accessible here.


#6

Hi Issac,

Yes I am using correct key. When I am using content_group_id it’s returning null but when removing that it’s returning all blog posts.

Still I will check more on this tomorrow morning and will let you know about my finding.

Thanks for the the reply :slight_smile:


#7

I tried again today, For 3 to 4 times it returned Null but after that its returning the post. Not sure what was going wrong though :frowning:

Thanks


#8

Hey, @Sabita_Sahoo.

So you're no longer experiencing the issue? That's so strange!

I tested with your API key in Postman and successfully retrieved the post once again. Have you been testing in a REST client or your app? If you try in Postman or another client, do you receive the same results?


#9

Hi Issac,

Its working fine now. I was directly trying in our application.

Thanks for you quick responses :slight_smile: