Created
June 26, 2020 16:50
-
-
Save thisismattmiller/115b5e194183e159dd72e016e2fa2b97 to your computer and use it in GitHub Desktop.
This file contains 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
import requests | |
import time | |
import json | |
headers = {'X-GraphDB-Password': 'XXXXXXXXXX'} | |
r = requests.post('http://IPADDRESS:7200/rest/login/USERNAME',headers=headers) | |
token = r.headers['Authorization'] | |
files = ["entities","genres","geonames","instruments","roles","venues","works","events"] | |
for f in files: | |
data_body = { | |
"baseURI": None, | |
"context": f'http://data.carnegiehall.org/{f}', | |
"data": f'https://PUBLICADDRESSOFTHERDFFILES/{f}.nt', | |
"forceSerial": False, | |
"format": "", | |
"message": "", | |
"name": f"http://data.carnegiehall.org/{f}", | |
"parserSettings": { | |
"failOnUnknownDataTypes": False, | |
"failOnUnknownLanguageTags": False, | |
"normalizeDataTypeValues": False, | |
"normalizeLanguageTags": False, | |
"preserveBNodeIds": False, | |
"stopOnError": True, | |
"verifyDataTypeValues": False, | |
"verifyLanguageTags": True, | |
"verifyRelativeURIs": True, | |
"verifyURISyntax": True | |
}, | |
"replaceGraphs": [f'http://data.carnegiehall.org/{f}'], | |
"status": "PENDING", | |
"timestamp": int(time.time()), | |
"type": "url" | |
} | |
headers = {'Authorization': token, 'Content-Type': 'application/json', 'Accept': 'application/json, text/plain'} | |
print(headers) | |
print(data_body) | |
data_body=json.dumps(data_body) | |
r = requests.post('http://IPADDRESS:7200/rest/data/import/upload/USERNAME/url',headers=headers, data=data_body) | |
print(r.text) | |
print(r.status_code) | |
time.sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment