...
The programmatic access works with a POST method to an action, as part of the path to the action includes your Organisation GUID, this can be found in your dcat “@id" key and is the alphanumeric string between “….io/org/” and “/dcat/…” so “28ccd497-7acd-4470-bd17-721d5cbbd6ef” in the example below. Note this is also available in the dcat url and is required when making API calls to datasets
...
A link to your DCAT can be found on a drop-down menu below the logo on your Organisation page, as shown below. (Select ‘Public’ in the menu.)
...
uSmart Actions
View a datasets meta data, dataset:view
...
Code Block | ||||
---|---|---|---|---|
| ||||
import json import os import requests # Generates the signed request to load the data into AWS def generatePutRequest_from_s3(fileName): url = "https://data.usmart.io/org/[Your Organisation GUID]/s3:generatePutRequest" payload = json.dumps({ "fileName": fileName }) headers = { 'api-key-secret': '[your api-key-secret]', 'api-key-id': '[your api-key-id]', 'Content-Type': 'application/json', } response = requests.request("POST", url, headers=headers, data=payload) return response.json() def dataset_file_update(filename, file_guid): getS3Putrequest = generatePutRequest_from_s3(filename) signedRequest_url = getS3Putrequest["result"]["signedRequest"] with open(filename, 'rb') as f: headers = { 'Content-Type': getS3Putrequest["result"]["contentType"] } http_response = requests.put(signedRequest_url, headers=headers, data=f) fileSize = os.path.getsize(filename) url = "https://data.usmart.io/org/[Your Organisation GUID]/file:updateRevision" payload = json.dumps({ "reference": getS3Putrequest["result"]["reference"], "fileName": filename, "fileGUID": file_guid, "fileSize": fileSize, "action": "file:updateRevision" }) headers = { 'api-key-secret': '[your api-key-secret]', 'api-key-id': '[your api-key-id]', 'Content-Type': 'application/json', } response = requests.request("POST", url, headers=headers, data=payload) return response.json() # Example function call filename = r"[Your file here]" file_guid = "[your file GUID]" output = dataset_file_update(filename, file_guid) print(output) |
...