2

We are trying to figure out how to get the answers for a given question ID in JSON or XML instead of HTML - so far for a URL like this:

https://api.stackexchange.com/2.2/questions/52533798/answers?order=desc&sort=activity&site=stackoverflow

We are getting results like this:

{
  "items":[
    {
      "owner":{
        "reputation":1,
        "user_id":9778142,
        "user_type":"registered",
        "profile_image":"https://i.stack.imgur.com/B1z6z.jpg?s=128&g=1",
        "display_name":"Rob Lewis",
        "link":"https://stackoverflow.com/users/9778142/rob-lewis"
      },
      "is_accepted":false,
      "score":0,
      "last_activity_date":1539215475,
      "creation_date":1539215475,
      "answer_id":52750264,
      "question_id":52533798
    }
  ],
  "has_more":false,
  "quota_max":300,
  "quota_remaining":260
}

Which is a user object that contains the answer_ID - is there a way to get the actual answer text?

1

1 Answer 1

7

The body and body_markdown fields are not in the default filter. Adding a filter that includes those fields will return them.

/2.2/questions/52533798/answers?order=desc&sort=activity&site=stackoverflow&filter=!9Z(-wzfpy

Creating filters can be a bit tricky, specially if you're new to them. I have an extensive answer written here: How to create API filters?

An appropriate duplicate to your question on StackApps is: How to get question body (markdown) in the API response using filters?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .