Hi there,
My final goal is to upload a file into a foundry dataset.
For that, I get the transaction id thanks to this documentation :
https://www.palantir.com/docs/foundry/api/datasets-v2-resources/transactions/create-transaction/.
import requests
HOSTNAME = <your_hostname>
TOKEN = <your_token>
headers = {
"content-type": "application/json",
"authorization": "Bearer {}".format(TOKEN)
}
request_body={"transactionType":"SNAPSHOT"}
response = requests.post('https://{}/api/v1/datasets/<your_rid>/transactions?branchId=master'.format(HOSTNAME), headers=headers, json=request_body)
print(response)
Then, I’m using the code based on this page https://www.palantir.com/docs/foundry/api/datasets-v2-resources/files/upload-file
The python code which allows to push the file stored in a local computer is:
import requests
HOSTNAME = <your_hostname>
TOKEN = <your_token>
headers = {
"content-type": "application/octet-stream",
"authorization": "Bearer {}".format(TOKEN)
}
response = requests.post('https://{}/api/v2/datasets/<your_rid>/files/2020/09/30/trades.csv/upload?branchName=master&transactionType=APPEND&transactionRid=<your_rid>'.format(HOSTNAME), headers=headers, data=open('/path/to/file', 'rb'))
print(response)
In the response variable I’m able to identify dataset rid and transaction id but I don’t know what “/2020/09/30/trades.csv” means in the path. I guess that’s why the code doesn’t work.
Any help would be greatly appreciated.