0

After get the answer with API, we get an object without a body.

{
  "items": [
    {
      "owner": {
        "reputation": 31,
        "user_id": 7256724,
        "user_type": "registered",
        "profile_image": "https://i.stack.imgur.com/pQ5II.jpg?s=128&g=1",
        "display_name": "Dzinot",
        "link": "https://stackoverflow.com/users/7256724/dzinot"
      },
      "is_accepted": false,
      "score": 2,
      "last_activity_date": 1494515438,
      "creation_date": 1494515438,
      "answer_id": 43919322,
      "question_id": 18987292
    }
  ],
  "has_more": false,
  "quota_max": 10000,
  "quota_remaining": 9401
}

How to receive the body of the answer?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
sdfgsdgsgr
  • 95
  • 1
  • 1
  • 8

1 Answers1

1

You can retrieve the body by adding a query parameter of filter=withbody. For example, when /2.2/answers/43919322?order=desc&sort=activity&site=stackoverflow in URL of your question is used, the URL is as follows.

https://api.stackexchange.com/2.2/answers/43919322?order=desc&sort=activity&site=stackoverflow&filter=withbody&access_token=#####&key=#####

If you want to retrieve the data using curl, you can use this.

curl "https://api.stackexchange.com/2.2/answers/43919322?order=desc&sort=activity&site=stackoverflow&filter=withbody&access_token=#####&key=#####" | gunzip

Reference :

If I misunderstand your question, I'm sorry.

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • Thanks. That's it. "withbody" works, but for example if I wanted to get comments, I type "withcomments" and it does not work. – sdfgsdgsgr Jan 31 '18 at 21:10
  • @sdfgsdgsgr When you want to retrieve comments, please check inbox. The detail information is https://api.stackexchange.com/docs/inbox But the full body of comments cannot be retrieved. In my environment, this is the same result. About this, please check https://stackapps.com/questions/6490/body-of-inbox-item-returning-only-excerpt-not-full-body – Tanaike Jan 31 '18 at 21:59
  • I do not think we understand each other. I do not want to get a comment from inbox. I want to get comments or answers from questions or answers. https://zapodaj.net/0d35194e03fa9.png.html According to this site https://api.stackexchange.com/docs/types/question question has a response in a non-default filter. That's why I'm doing the query at https://api.stackexchange.com/docs/questions#order=desc&sort=activity&filter=withanswers&site=stackoverflow&run=true But the website is silent https://zapodaj.net/8b1871d627569.png.html. I can not get get or answers or comments. – sdfgsdgsgr Jan 31 '18 at 22:53
  • @sdfgsdgsgr I'm sorry for the inconvenience and my poor English skill. I think that your additional question is required to be seen by not only my but also other users. By this, it might lead to the solution or workaround. So can you post it as a new question? Also I would like to look for the solution. – Tanaike Jan 31 '18 at 23:10