Troubleshooting of WikiData API

From LemonWiki共筆
Jump to navigation Jump to search

Troubleshooting of WikiData API OR Wikipedia API

How to fix the error Unrecognized value for parameter "props": sitelinks/zhwiki[edit]

When I request the API url: https://www.wikidata.org/w/api.php?action=wbgetentities&format=json&props=labels%7Csitelinks/zhwiki&ids=Q21007575&languages=zh , I met the error message:

{
    "warnings": {
        "wbgetentities": {
            "*": "Unrecognized value for parameter \"props\": sitelinks/zhwiki"
        }
    },
    "entities": {
        "Q21007575": {
            "type": "item",
            "id": "Q21007575",
            "labels": {}
        }
    },
    "success": 1
}

Root cause

  • The page did not have the property sitelinks/zhwiki

Solution

How to fix the error "Our servers are currently under maintenance or experiencing a technical problem."[edit]

When using PHP curl the url https://zh.wikipedia.org/w/api.php?action=query&prop=extracts&titles=<title>&explaintext=1&formatversion=2&format=json met the following error

Error
Our servers are currently under maintenance or experiencing a technical problem. Please try again in a few minutes.

See the error message at the bottom of this page for more information.

Solution

  • Try to send the same request later
  • Change the URL parameter (default) strict-origin-when-cross-origin to origin=* e.g. https://zh.wikipedia.org/w/api.php?action=query&prop=extracts&titles=<title>&explaintext=1&formatversion=2&format=json&origin=*[1]

Further reading[edit]

References[edit]