I need to check to see if a dataset exists within a Palantir Foundry directory, and if it doesn't exist, initiate the dataset creation process. I specifically want to look for a specified table name within the directory, and if it exists, return the dataset RID associated with that table. However, I'm having difficulty doing the first step. I have the following code:
def list_datasets_in_foundry_directory(
token,
base_url,
parent_folder_rid):
headers = {
"authorization": "Bearer {}".format(token)
}
response = requests.get(f'{base_url}/api/v1/directories/{parent_folder_rid}/datasets', headers=headers)
datasets = response.json()
return datasets
But the response returns a 404 error.
I found the answer in this StackOverflow post. Here is the working code: