View difference between Paste ID: b6PQECrF and 14zTJeSi
SHOW: | | - or go back to the newest paste.
1
var api = new mw.Api();
2
api.get({
3
  action:'query',
4
  continue:'',
5
  meta:'tokens',
6
  format:'json'
7
}).done(function(token) {
8
  api.post({
9
    action: 'wbcreateclaim',
10
    entity: 'Q4115189',
11
    property: 'P901',
12
    snaktype: 'value',
13
    token: token.query.tokens.csrftoken,
14
    value: {'entity-type': "item", 'numeric-id':1}
15
  }).done(function(data) {
16
    console.log(data);
17
  });
18-
});
18+
});
19
20
/*
21
Error message
22
23
{
24
    "servedby": "mw1131",
25
    "warnings": {
26
        "main": {
27
            "*": "Parameter 'value' uses unsupported PHP array syntax"
28
        }
29
    },
30
    "error": {
31
        "code": "param-missing",
32
        "info": "A parameter that is required was missing (A value needs to be provided when creating a claim with PropertyValueSnak snak)",
33
        "messages": [
34
            {
35
                "name": "wikibase-api-param-missing",
36
                "parameters": [],
37
                "html": {
38
                    "*": "A parameter that is required was missing"
39
                }
40
            }
41
        ],
42
        "*": "See https://www.wikidata.org/w/api.php for API usage"
43
    }
44
}
45
*/