3

I have a script to help manage a Google Blogger site and it's been running for little more than a year without any issues.

A couple of weeks ago, the script stopped working properly, instead returning "404 Not Found" errors when requesting a list of comments for a blog post.

ERROR: <HttpError 404 when requesting https://www.googleapis.com/blogger/v3/blogs/<RedactedBlogId>/posts/<RedactedPostId>/comments?status=live&alt=json&maxResults=200 returned "Not Found">

I've also tried the "listByBlog" resource

ERROR: <HttpError 404 when requesting https://www.googleapis.com/blogger/v3/blogs/<RedactedBlogId>/comments?status=live&alt=json&maxResults=200 returned "Not Found">

Comparing with Try this API

What's a little bit weird is that when I use "Try this API" with same blogId and postId, I get the expected response.... IF I also prefix postId with a forward-slash, i.e. /<RedactedPostId> Without the forward slash prefix, I get an empty result. I discovered this by accident when copy/pasted the postId. If I check the network tab in devtools, the requested URL (when receiving a correct response) is https://content.googleapis.com/blogger/v3/blogs/<RedactedBlogId>/posts/%2F<RedactedPostId>/comments?key=<RedactedKey>

The only major difference (apart from the really weird prefix-requirement...) is the domain name.

Python client library

Using the Python Client Library v1.6.5, my script works fine, up to this point. I'm able to request blog info and list of posts just fine. So I have ruled out issues with authentication/authorization.

Conclusions

  1. I don't believe authorization is the issue since the other resources works
  2. I have not done any changes in my script ... it just stopped working one day
  3. upgrading to latest version of python client library did not resolve it
  4. the fact I have to prefix with / when "trying" the API on the documentation site suggests something is fishy with the API resource...
  5. Prefixing postId with / in my python script does not resolve the issue
  6. Just to be clear, blogId and postId ARE correct, I've double-checked, triple checked, quadruple-checked and copy-pasted exact same values to "Try this API" which, apart from /-prefix, works as expected.
tehhowch
  • 9,645
  • 4
  • 24
  • 42
Adam B
  • 506
  • 1
  • 5
  • 13

1 Answers1

2

I tested and found that when there are no comments present in a particular type of status , it gives a 404 error rather than returning an empty result. To explain with a live example, for status live, I see the comments as usual for -

https://www.googleapis.com/blogger/v3/blogs/2295610366269213074/posts/1288081480380921154/comments?status=live&alt=json&maxResults=200&key=KEY

But for status spam, I get a 404 error as there are currently no comments in the spam queue for that particular post -

https://www.googleapis.com/blogger/v3/blogs/2295610366269213074/posts/1288081480380921154/comments?status=spam&alt=json&maxResults=200&key=KEY

If you are only trying to access the published comments for a post in your application, then you can use the publically accessible Feed URL with the format -

https://www.blogger.com/feeds/<BlogID>/<PostID>/comments/default?alt=json&max-results=200
Prayag Verma
  • 5,581
  • 3
  • 30
  • 56
  • I thought you were right first. But can't confirm what you're saying. I have live (published) comments but I can't list *any* comments. Even without the status= filter I get a 404 when using the python client sdk library. And if I add a filter for comments which does not exist in the "try this api", I still get a 200 response even if the result is empty. Why is it so different? It seems to produce three different result (yours), (mine) and a third when using "try this api". – Adam B Feb 23 '18 at 20:16
  • Tried out using API Key, it works as you describe. It does not work using the python client library (which uses OAuth) – Adam B Feb 23 '18 at 21:26
  • 2
    The behavior of the API is a bit erratic. Raising this on their developer forum might be helpful - https://groups.google.com/forum/#!forum/bloggerdev . Someone raised an issue similar to this a month back ( https://groups.google.com/forum/#!topic/bloggerdev/_-LtSQ3Bu64 ) but no one seems to have replied yet – Prayag Verma Feb 23 '18 at 23:19