Last active
January 13, 2021 20:30
-
-
Save maxlath/18ab1f0eaf5bf5201fd392d7bb988e45 to your computer and use it in GitHub Desktop.
add publishers to editions on inventaire.io using curl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use your username and password to get session cookies | |
INV_USERNAME=foo | |
INV_PASSWORD=bar | |
INV_SESSION_COOKIES=$(curl -v 'https://inventaire.io/api/auth?action=login' -d "{\"username\":\"$INV_USERNAME\",\"password\":\"$INV_PASSWORD\"}" 2>&1 | grep 'Set-Cookie: inventaire:session' | awk '{print $3}' | xargs echo) | |
add_claim(){ | |
uri=$1 | |
property=$2 | |
value=$3 | |
curl -s -XPUT "https://inventaire.io/api/entities?action=update-claim" -H "Cookie: $INV_SESSION_COOKIES" -H "Content-Type: application/json" -d "{\"uri\":\"${uri}\",\"property\":\"${property}\",\"new-value\":\"${value}\"}" | |
} | |
add_publisher(){ | |
inv_add_claim "$1" wdt:P123 "$2" | |
} | |
add_publisher inv:1b7b119485923797ed33e2fd292ae299 wd:Q1285349 | |
add_publisher inv:3fdcb00a816ff62049c076960eef2080 wd:Q1285349 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment