forked from wmde/WikibaseReconcileEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (39 loc) · 1.31 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import requests
from requests_oauthlib import OAuth1
from pprint import pprint
data = {
"reconcile": {
"wikibasereconcileedit-version": "0.0.1",
"urlReconcile": "P1",
},
"entity": {
"wikibasereconcileedit-version": "0.0.1/minimal",
"statements": [
{
"property": "P1",
"value": "https://gitlab.com/OSEGermany/ohloom"
},
{
"property": "P2",
"value": "OHLOOM"
},
{
"property": "P3",
"value": "https://gitlab.com/OSEGermany/ohloom/-/raw/834222370f34ad2a07d0e41d09eb54378573b8c3/sBoM.csv"
},
],
},
#"token": "" CSRF token to be supplied if not using OAuth
}
# These are displayed ONCE when the owner-only consumer is created
consumer_key = ''
consumer_secret = ''
access_token = ''
access_secret = ''
auth = OAuth1(consumer_key, consumer_secret, access_token, access_secret)
# CSRF token to be supplied if not using OAuth
#result = requests.get(url='https://wikibase-reconcile-testing.wmcloud.org/w/api.php', params={'action': 'query', 'meta': 'tokens', 'format': 'json'}, auth=auth)
#token = result.json()['query']['tokens']['csrftoken']
#data['token'] = token
result = requests.post(url='https://wikibase-reconcile-testing.wmcloud.org/w/rest.php/wikibase-reconcile-edit/v0/edit', json=data, auth=auth)
pprint(vars(result))