Nux created this task. Nux added projects: Wikidata, MediaWiki-REST-API. Restricted Application added a subscriber: Aklapper.
TASK DESCRIPTION **Steps to replicate the issue** (include links if applicable): Trying to add property with coordinates: - Read claim-id with wbgetentities. - Removed claim (P625 <https://phabricator.wikimedia.org/P625>) with wbremoveclaims. - Adding new value with wbcreateclaim. var req = api.postWithToken('csrf', { action: 'wbcreateclaim', entity: 'Q30049941', property: 'P625', snaktype: 'value', value: { "latitude": ll.lat, "longitude": ll.lon, "globe": "http://www.wikidata.org/entity/Q2", "precision": 0.000001 }) }) **What happens?**: The code didn't work. The submitted values were in PHP array syntax (e.g. `value[globe]`), and the API expected a JavaScript/JSON object. **What should have happened instead?**: The value should either be encoded as an object, or the other syntax should be supported. By the way, it would be nice if the API responded with a 400 error to indicate a bad payload, but I guess that might require a more significant change... **Software version** (skip for WMF-hosted wikis like Wikipedia): WD **Other information** (browser name/version, screenshots, etc.): The code that did work (workaround): var api = new mw.Api(); var ll = { lat: 51.170230459745, lon: 16.146803039764 }; var req = api.postWithToken('csrf', { action: 'wbcreateclaim', entity: 'Q30049941', property: 'P625', snaktype: 'value', value: JSON.stringify({ "latitude": ll.lat, "longitude": ll.lon, "globe": "http://www.wikidata.org/entity/Q2", "precision": 0.000001 }) }) .done(function (re) { console.log(`code: ${re.code}, success: ${re.success}`, re); }) .fail(function (re, r2, r3, r4) { //debugger; console.warn(re, { code: r2?.error?.code, info: r2?.error?.info, warn: JSON.stringify(r2?.warnings) }); }) ; TASK DETAIL https://phabricator.wikimedia.org/T345979 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: Nux Cc: Aklapper, Nux, Danny_Benjafield_WMDE, Astuthiodit_1, karapayneWMDE, Invadibot, maantietaja, ItamarWMDE, Akuckartz, apaskulin, Nandana, Lahi, Gq86, Xinbenlv, GoranSMilovanovic, QZanden, LawExplorer, _jensen, rosalieper, Scott_WUaS, Wikidata-bugs, aude, Mbch331
_______________________________________________ Wikidata-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected]
