Page MenuHomePhabricator

Contributor sets page description
Closed, ResolvedPublic1 Estimated Story Points

Description

"As a Contributor, I want to set the description of a page, so that readers will have context for what the page is about."

This is a uniform interface for setting the description of the page, whether the description is stored in wikibase or in a local property. The description is mapped to a sub-resource of the page.

If this wiki uses local descriptions, this method should either replace a call to the short description template if it already exists anywhere in the page content, or prepend a call to the short description template if it doesn't.

If this wiki uses Wikidata descriptions, it should write to Wikidata.

see T259622 for configuration options.


PUT /page/{title}/description

Set the description of the page. It will be created if it does not already exist.

Notable request headers: none

Request body: JSON object with the following property

  • description: string, new description of the page, no wikitext or HTML markup

Status:

  • 200: OK, description was updated
  • 403: Not allowed to update the description
  • 404: No such page

Notable response headers: none

Response body: JSON object

  • description: echo back the description that was sent

Event Timeline

eprodromou updated the task description. (Show Details)
eprodromou updated the task description. (Show Details)
Pchelolo set the point value for this task to 1.Sep 9 2020, 3:42 PM

Setting the description in Wikidata requires a language parameter. We can infer the language from the domain, however for wikis with language variants the user should be specifying the variant. I propose to use Content-Language header for this purpose, defaulting to language inferred from the default wiki content language is not specified.

Change 627378 had a related patch set uploaded (by Ppchelko; owner: Ppchelko):
[mediawiki/services/mobileapps@master] WIP: Add REST api for short descriptions

https://gerrit.wikimedia.org/r/627378

Change 627378 merged by jenkins-bot:
[mediawiki/services/mobileapps@master] Add REST endpoints for short page descriptions.

https://gerrit.wikimedia.org/r/627378

Change 630671 had a related patch set uploaded (by Mholloway; owner: Michael Holloway):
[operations/deployment-charts@master] Update mobileapps to 2020-09-28-145812-production

https://gerrit.wikimedia.org/r/630671

Change 630671 merged by jenkins-bot:
[operations/deployment-charts@master] Update mobileapps to 2020-09-28-145812-production

https://gerrit.wikimedia.org/r/630671

Done:

curl -XPUT -H 'Content-Type: application/json' -H 'Authorization: Bearer $TOKEN' -H 'Content-Language: sr-ec' https://api.wikimedia.org/core/v1/wikipedia/sr/page/%D0%9A%D0%BE%D1%80%D0%B8%D1%81%D0%BD%D0%B8%D0%BA%3APchelolo%2FDescrTest/description -d "{\"description\":\"Мое тестовое описание\",\"comment\":\"Мой тестовый коммент\"}"
{"description":"Мое тестовое описание"}

Looking at the linked Wikidata item Q4115189: Serbian (Cyrillic script) - Мое тестовое описание

curl -H 'Accept-Language: sr-ec' https://api.wikimedia.org/core/v1/wikipedia/sr/page/%D0%9A%D0%BE%D1%80%D0%B8%D1%81%D0%BD%D0%B8%D0%BA%3APchelolo%2FDescrTest/description
{"description":"Мое тестовое описание"}

curl -H 'Accept-Language: sr-el' https://api.wikimedia.org/core/v1/wikipedia/sr/page/%D0%9A%D0%BE%D1%80%D0%B8%D1%81%D0%BD%D0%B8%D0%BA%3APchelolo%2FDescrTest/description
{"status":404,"type":"not_found","title":"Short description not found","detail":"404: not_found","method":"GET","uri":"/sr.wikipedia.org/v1/page/description/%D0%9A%D0%BE%D1%80%D0%B8%D1%81%D0%BD%D0%B8%D0%BA%3APchelolo%2FDescrTest"}

Deleting:

curl -XDELETE -H 'Authorization: Bearer $TOKEN' -H 'Content-Language: sr-ec' https://api.wikimedia.org/core/v1/wikipedia/sr/page/%D0%9A%D0%BE%D1%80%D0%B8%D1%81%D0%BD%D0%B8%D0%BA%3APchelolo%2FDescrTest/description

Looking at the related data item - the description disappeared.

When testing this, please be VERY careful cause your edits are going to real Wikidata. Please use Q4115189 as a testbed. Prior to testing you need to add a site link to the article you will be using for testing.

Note that apps don't use OAuth, and need to pass a csrf token. Is there a way to pass the token in the request body?

eprodromou added a subscriber: apaskulin.

Looks good. @apaskulin note that @Pchelolo went with using the DELETE verb instead of setting a null value.

Added to API Portal reference docs. Feedback and direct edits welcome!

Note that apps don't use OAuth, and need to pass a csrf token. Is there a way to pass the token in the request body?

Sorry to bump this question, but I'm still curious if it's possible to use this API without OAuth.

Currently it's not. It's possible to add a feature like that, but the API is exposed via the API Gateway currently which is all OAuth based.

No response, closing.