8

I'm currently trying to create a bot to submit some edits to questions on Stack Overflow. This bot currently has < 2k rep, but I'm able to submit these edits to the website manually, without any issue. The plan was to make a simple "title bot" removing obvious "in C#" tags in the title, but my plan was to extend it to fix minor obvious grammatical mistakes as well i => I, etc. Until the bot hits 2k rep, it would need to submit these manually, and have them be approved.

Is it possible to allow < 2k accounts to use the /edit endpoint? I'm assuming it should follow the normal procedure of having to be manually be approved until 2k rep. Currently, the API returns:

{
  "error_id":407,
  "error_message":"Account is not allowed to suggest edits",
  "error_name":"write_failed"
}
2
  • 2
    For write access with the API you need a stack apps post first. I see you've got one already, but just want to check (it's easy to forget to do!) -- have you registered a new application and set the post in your app settings on stack apps? You'd also need an access token for write access Commented Feb 11, 2019 at 20:40
  • 1
    @ᔕᖺᘎᕊ Yes: I do have write access, and I set that up properly.
    – Blue
    Commented Feb 11, 2019 at 21:47

1 Answer 1

11

API version 2.3 has been released; it has a new method, /questions/{id}/suggested-edit/add and a similar one for answers (/answers/{id}/suggested-edit/add). At the time this question was asked, this version of the API was already available but undocumented. I figured this out by monitoring requests sent by the Stack Exchange mobile app using Fiddler.

I would share some sample code but for you it isn't necessary: the body of the request is the same as for regular edits. You literally only need to change the endpoint, but if and only if you don't have privileges to normally edit the post. That means you need to check:

  • if the post is Community Wiki or not
  • the reputation of your account
  • the site_state of the site (in your case, not necessary since you've limited your bot to Stack Overflow):
    • normal, when you need 2000 reputation
    • open_beta and closed_beta when you need 1000
    • or something else – that site is an open_beta according to the API

There is a shortcut described here but I haven't tested it. Otherwise you'll call the wrong endpoint and the call with fail.

2
  • IMO, this shouldn't be needed AT ALL. If I hit the /edit endpoint, it should automatically submit a suggested-edit, just like the website does currently.
    – Blue
    Commented Feb 11, 2019 at 22:29
  • 3
    I agree, but some scattered comments/answers (e.g. this one) give me the feeling v2.3 was only pushed to make the apps working (and granted, it does), without thinking too much about the consequences.
    – Glorfindel Mod
    Commented Feb 13, 2019 at 7:57

You must log in to answer this question.

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