Guest User

wbcreateclaim

a guest
Mar 23rd, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. api.get({
  2.   action:'query',
  3.   continue:'',
  4.   meta:'tokens',
  5.   format:'json'
  6. }).done(function(token) {
  7.   api.post({
  8.     action: 'wbcreateclaim',
  9.     entity: 'Q4115189',
  10.     property: 'P901',
  11.     snaktype: 'value',
  12.     token: token.query.tokens.csrftoken,
  13.     value: '{"entity-type":"item","numeric-id":1}' // String now
  14.   }).done(function(data) {
  15.     console.log(data);
  16.   });
  17. });
  18.  
  19. /*
  20. Error message
  21.  
  22. {
  23.     "servedby": "mw1231",
  24.     "error": {
  25.         "code": "invalid-snak",
  26.         "info": "Invalid snak (Can only construct StringValue from strings)",
  27.         "messages": [
  28.             {
  29.                 "name": "wikibase-api-invalid-snak",
  30.                 "parameters": [],
  31.                 "html": {
  32.                     "*": "Invalid snak"
  33.                 }
  34.             }
  35.         ],
  36.         "*": "See https://www.wikidata.org/w/api.php for API usage"
  37.     }
  38. }
  39. */
Advertisement
Add Comment
Please, Sign In to add comment