1

I was wondering if I'm allowed to pass a filter to methods that use write access? Like for example /answers/{id}/accept. There is no "filter" parameter, and changing the filter doesn't seem to change the URL, though "preview" doesn't do this too.

I'll vote for yes, but I don't have any API key or access token available, so I can't test this...

1 Answer 1

2

Yes. You can pass a filter, and you should (for all the standard reasons).

First: On the doc page, changing the filter or preview, etc. will not change the URL for write methods.
Write methods must POST to the API, which means that parameters are supposed to be sent form encoded, not in the URL. (This API bakes some things, like post ID, into the route. But, it is still not in the search/query/parameter part of the URL.)


Anyway, filters work with write methods.
For example, when my own app posts to:
          https://api.stackexchange.com/2.2/answers/7151/accept

with no filter specified, it gets:

items: [{
    owner: {
        reputation: 695,
        user_id: 42239,
        user_type: "registered",
        profile_image: "https://i.sstatic.net/zweIW.png?s=128&g=1",
        display_name: "Bhargav Rao",
        link: "https://stackapps.com/users/42239/bhargav-rao"
    },
    is_accepted: true,
    score: 3,
    last_activity_date: 1485020864,
    last_edit_date: 1485020864,
    creation_date: 1482739375,
    answer_id: 7151,
    question_id: 7057
}],
has_more: false,
quota_max: 10000,
quota_remaining: 9994

-- which has a lot of properties that I don't care about.


But when I post with a sensible filter (filter=!8IfkvFvN6wVk.*awhCzFz), I get:

items: [{
    owner: {
        display_name: "Bhargav Rao"
    },
    is_accepted: true,
    score: 3,
    answer_id: 7151
}],
has_more: false,
quota_max: 10000,
quota_remaining: 9993,
page: 1,
page_size: 30


Note that that doc page, like most (¿all?) of the write-access doc pages, appears to be substantially broken. That is, I plug valid values into the inputs and get invalid (or no) results

2

You must log in to answer this question.

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