6

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"
}
9

The trick is to use the undocumented version 2.3 of the API. It has a new method, /questions/{id}/suggested-edit/add and a similar one for answers (/answers/{id}/suggested-edit/add). 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.

  • 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. – FrankerZ Feb 11 at 22:29
  • 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 2 days ago

You must log in to answer this question.

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