There is no link field on notification. Is this by design or a bug? If it's by design can it be changes so it's included, I can't see how to build the URL with only a post id, and not know what type of post it is?
2 Answers
Notifications typically contain links within their bodies. They're considerably more free-form than inbox_items, in that they're not typically attached to a post.
Notifications only even have directly attached posts (at time of writing) in the bounty and edit cases.
Note that if there's a post_id present, you can query /posts/{ids} to get a link. Alternatively, you can do as George suggested; those links aren't getting broken anytime soon.
tl;dr - notifications wouldn't typically have links, but we'd have to do a lot of work just in case. The omission of link
is by design for v2.1.
-
Ah right, I was stripping all the HTML, probably should have checked the raw data more thoroughly before posting. But it seems most (if not all) notifications only have one link in them? Would it be possible to add a link field and have it contain the link that is in the body? Commented Jul 21, 2012 at 0:14
This is possible. Just use the format below:
http://some_site.stackexchange.com/q/
{post_id}
This will work regardless of whether the post is a question or answer. If the post is an answer, the site will automatically redirect you to the URL for the answer.
Example for this answer: https://stackapps.com/q/3550
-
But why is this inconsistent with many 2.0 items.
link
was introduced to avoid having to build the URL yourself? Commented Jul 20, 2012 at 18:02 -
Well, I can't comment on that - I can only tell you how I work around the problem. Commented Jul 20, 2012 at 18:17