Skip to content

Instantly share code, notes, and snippets.

@maxlath
Last active January 13, 2021 20:30
Show Gist options
  • Save maxlath/18ab1f0eaf5bf5201fd392d7bb988e45 to your computer and use it in GitHub Desktop.
Save maxlath/18ab1f0eaf5bf5201fd392d7bb988e45 to your computer and use it in GitHub Desktop.
add publishers to editions on inventaire.io using curl
# 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