API talk:Edit

Dear early adopters, does the edit action work for anyone? I try hard but can't get it to work with an php client. Like suggested at the login-discussion site i now use the Snoopy library to set the cookies for the mw system (hopefully this is not necessary anymore in the near future!). I am able to login and to request a edit-token. but if i try to edit the content, i get the result Conflict detected. Is it possible to get some more details about the conflict? Any logfiles or something else which could help?
 * Ah, found the conflict myself: i was using the false epedittime. Now it works!

Create pages
How do I need to change the code in order to create, rather than edit, a page? Thanks.

Sorry for the late response. Create and edit are the same from the API point of view. eptext=WikiText parameter is the whole article content, including changes when the article has been edited, or new content when eptitle did not exist. --Raquel.Frisa 10:07, 19 October 2007 (UTC)


 * one little difference would be useful: sometimes you want to change an article only if it exists, but not create it if it doesn't. an example: inserting a speedy-deletion-template should not recreate an already deleted article. -- ∂ 01:48, 21 October 2007 (UTC)
 * What about you just check for the article's existence using api.php?action=query&prop=info&titles=hddfal? --Catrope 12:26, 21 October 2007 (UTC)
 * Race condition -- ∂ 15:03, 25 October 2007 (UTC)
 * You'll get an w:Wikipedia:Edit conflict, won't you? --Catrope 22:16, 30 October 2007 (UTC)
 * that would only be possible if i fetched the edittoken before the article has been deleted, and there's no way to ensure that. -- ∂ 13:35, 5 November 2007 (UTC)
 * True. There should probably be an epNoCreate parameter. --Catrope 15:08, 5 November 2007 (UTC)

Can't pass &prop via php
$titleURL = "action=query&prop=info&titles=BatPresubmitTest&intoken=edit&lgtoken=". $getLoginResponse['login']['lgtoken']."&lgusername=". $getLoginResponse['login']['lguseprname']."&lguserid=". $getLoginResponse['login']['lguserid']. "&format=php";

$getTitleResponse = unserialize(getURL($apiURL,$titleURL)); function getURL($url,$vars){ $ch = curl_init; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch,CURLOPT_POSTFIELDS,$vars); $content = curl_exec($ch); curl_close($ch); return $content; } No matter how I try this &prop gets encodes to &#8733; Does anyone have a clue how to that parameter without the param getting encoded/decoded to a char? --jason 04:08, 13 November 2007 (UTC)
 * That's weird. You could:
 * Try to use &amp; rather than &
 * Use Snoopy, which doesn't have this problem (and allows you to specify post data as an array instead).
 * --Catrope 14:25, 13 November 2007 (UTC)
 * Thanks - Solved with this (apparently tokens arent working - go snoopy)
 * --jason 18:03, 13 November 2007 (UTC)

function getSnooped($url,$vars){ include "Snoopy.class.php"; $snoopy = new Snoopy; $snoopy->cookies["inside_wikiToken"] = $_COOKIE["inside_wikiToken"]; $snoopy->cookies["inside_wikiUserID"] = $_COOKIE["inside_wikiUserID"]; $snoopy->cookies["inside_wikiUserName"] = $_COOKIE["inside_wikiUserName"]; $snoopy->cookies["inside_wiki_session"] = $_COOKIE["inside_wiki_session"]; $snoopy->submit($url,$vars); $snoopy->setcookies; return $snoopy->results; }

Odd - is this enabled?
Maybe I'm missing something -- heck, I probably am :)

Say, I try a request like this:

Array (   [epedittoken] => 3b70467f9655b80195b13e7765437dc0+\    [epsummary] => SxWiki: Testing    [eptext] => New revision here    [lgtoken] =>     [minoredit] => no    [epuserid] => 4746784    [testrun] => no    [disablemerge] => no ) I'm trying to send it to this URL: http://en.wikipedia.org/w/api.php?action=edit&title=User%3ASQL%2FSandbox

No matter what I do, I get:

unknown_action: Unrecognised value for parameter 'action' 1.13: Still same problem - User:Dynasource
 * Did you remember to add  to LocalSettings.php? --77.164.182.8 17:52, 9 August 2008 (UTC)

Anyone know what the likely obvious thing I'm missing is? :) SQL Query me!  04:14, 15 November 2007 (UTC)
 * This is a proposed implementation that's only partially been written and is not yet available in the main source tree. It will be when it's been completed and tested. --Catrope 13:37, 15 November 2007 (UTC)


 * Gotcha, maybe the article should say so :) SQL Query me!  21:19, 15 November 2007 (UTC)

Just out of interest does anyone have an idea about when this is likely to be implemented, or what we can do to speed it up?? :) 84.68.125.79 21:59, 5 December 2007 (UTC)
 * It's gonna be implemented eventually. The Vodafone folks were supposed to be working on this, but have been inactive lately, so I'll take up their work soon. --Catrope 14:20, 6 December 2007 (UTC)

Is there is any update on when would this Edit/Create APIs be ready? Anyone working on this? Also what is it missing to make it work? Maybe we can help making it working...., thanks in advance for the update. --66.131.255.87 03:34, 19 February 2008 (UTC)
 * Action=edit is now finished, but it hasn't been enabled on Wikipedia and friends yet. --Catrope 13:15, 12 March 2008 (UTC)

unknown_action: Unrecognised value for parameter 'action'
I have version 1.12 installed, as well as both API parameters in the LocalSettings set to true; When i make a POST request to edit (action=edit), i am getting this error:  "unknown_action: Unrecognised value for parameter 'action'". Anyone know why I would be getting this? Isn't editing supposed to be supported for version 1.12? --Duke33 19:29, 12 April 2008 (UTC)
 * Oops, that should be 1.13. --Catrope 19:56, 13 April 2008 (UTC)


 * Me too :(
 * Go back, to trying again the parsed method by browsing.
 * --Covi 11:40, 3 May 2008 (UTC)

deadline to enable action=edit on Wikipedia?
If not soon, what method you'd suggest to use meanwhile? -- Григор Гачев 09:20, 14 August 2008 (UTC)
 * I don't think action=edit will be enabled on WMF wikis very soon. To make action=edit cooperate nicely with extensions, a rewrite of EditPage.php should really be done. I've done some of that rewriting already, but it'll take some time. In the meantime, you can use pywikipediabot. --Catrope 12:41, 15 August 2008 (UTC)
 * Sorry, I don't understand: does action=edit actually work but is disabled on Wikipedia, or is it unfinished and impossible to enable on any MediaWiki site? --217.117.119.246 02:16, 17 August 2008 (UTC)
 * action=edit works fine. It hasn't been enabled on WMF wikis (including Wikipedia) yet because it doesn't work too nicely with extensions yet. --Catrope 06:59, 17 August 2008 (UTC)
 * Is known when it will be activated on the WMF wikis? -- Fale
 * No. --Catrope 14:18, 17 August 2008 (UTC)

internal server error using edit
I´m trying to edit an article on en.wikipedia.org. The response I´m getting from the server seems ok when it returns a code error, like "cantcreate-anon" if the query doesn´t identify the user, "articleexists" if it is trying to create a page that already exists and the createonly parameter is set or "badtoken" if the token is not valid

But when the request seems to be all right I get an Internal Server Error (Http code 500).
 * This was fixed, see also 15420. --Catrope 21:20, 6 September 2008 (UTC)

Strange stuff ?
I've some problems using this editing API: Is there any info about this comportement, do I fortget someting ? I use Mediawiki 1.13.1. Charles 16:39, 5 October 2008 (UTC)
 * All parameters must be send in the url to be understand by the server, but I must use a POST request and fill the content with some dummy data. (why not passing the content of my page in the post?)
 * And the token is not received properly : the final caracter + is replaced with a space, and the token test fails.
 * You should urlencode the token so the  is encoded as  . Also, you shouldn't put dummy data in the POST body; instead, you should set the Content-Type to   and use the query string (e.g.   as the POST body. --Catrope 20:26, 5 October 2008 (UTC)
 * Ok for the urlencode. Stupid question, trivial answer... :-p
 * For the post problem, that's really strange. It works perfectly if I send a POST and send ma datas in the URL... Setting Content-Type to application/x-www-urlencoded changes nothing. URL's length is limited, so I have to fix it. If anybody have a suggestion? Charles 20:14, 6 October 2008 (UTC)
 * Ok, found. you must set content type to application/x-www-form-urlencoded (do not forget the form !). Thnak you for your help! Charles 20:20, 6 October 2008 (UTC)

token clarification
currently, the code for getting an edit token is given as follows:
 * api.php?action=query&prop=info|revisions&intoken=edit&titles=Main%20Page

this raises a question about the use of combined queries like '&prop=info|revisions'. how far can that be extended? is it restricted within general categories, or could we (if it made sense) do, say, a 'prop' and a 'list' command in the same query?

I think for the purposes of the documentation that we should drop the '|revisions' bit, which isn't necessary to get the token and last revision. I'll go ahead and edit that change in (feel free to revert if there's something I'm misunderstanding).

actually, I think there ought to be a 'API Programming Conventions' page that lays out some of these obscure details (like using a vertical bar to separate multiple options or actions, or sending combined requests). maybe combine it with the Formats page? --Ludwigs2 20:23, 14 October 2008 (UTC)
 * Stuff like  can be extended as far as you want, although duplicate values will be ignored. Combining ,   and even   in one request is also allowed. In short: in an   request, you can use any combination of query modules.
 * As I explained in my edit summary,  is not redundant, you need it to get the last revision's timestamp, which may be different from.
 * I thought using the pipe for multivalue parameters was documented somewhere, I'll check and add it if it isn't. I'll also add a note about combining query modules if there isn't one already. --Catrope 14:19, 15 October 2008 (UTC)


 * ah, ok, that makes sense. and thanks for adding the note.  :-)

Don't watch ?
Hi,

Is there an option for not modifying your watchlist, even though you have a preference like "Automatically watch all pages I edit" enabled ? The options available on the documentation are listed below. I was looking for something like the  but without "Remove".


 * : Add the page to your watchlist
 * : Remove the page from your watchlist, or don't add it even though you have a preference like "Automatically watch all pages I edit" enabled

--NicoV 10:26, 18 October 2008 (UTC)
 * No, there is no such option. I guess we kind of expect people to know whether they're watching a page and what their preferences are. --Catrope 21:00, 19 October 2008 (UTC)