We are delighted to share our new EIC Delivery Methodology for efficiently managing Saviynt Implementations and delivering quick time to value. CLICK HERE.

Dataset API syntax

DanJ
New Contributor III
New Contributor III

Hi all

We're attempting to use datasets for a new feature we're developing. I can't find the syntax for the API. Firstly, for anyone using the postman docs for getDatasetValues it tells you to send a JSON body with the GET (!?!?!?), but you don't need to do this, you can add to the URL params:

/getDatasetValues?datasetname=mydatasetname

But I have problems with the updating and creating of records. In the GUI it is possible to add a new record, but not to edit an existing one. In the API it is possible to edit an existing one - POST to /updateDatasetValues

{
"datasetname":"mydatasetname",
"myfield1":"valueA",

"updateattributes": {
"myfield2": "valueB"
}

finds the record with myfield1 = valueA and updates myfield2 to valueB

BUT I can't work out how to add a new record. I've tried all sorts of combinations but can't get it. Surely I don't need to use the GUI to add and the API to update? Nothing would surprise me with this API though.

2 REPLIES 2

DanJ
New Contributor III
New Contributor III

OK so my original question still stands, but I have found out how to upload a CSV file to the dataset. Bizarrely this doesn't overwrite the entire dataset, like in the GUI, but just adds new records.

Here is how this works if anyone is interested. It's best if you don't read the postman API reference as it's complete nonsense. In fact the example response is even an error 😄

 

{
  "msg": "Unexpected error occurred",
  "errorCode": 1
}

 

Instead, do this (powershell):

 

 

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer {{token}}")
$headers.Add("Content-Type", "application/json")

$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$multipartFile = "C:\temp\dataset_testing.csv"
$FileStream = [System.IO.FileStream]::new($multipartFile, [System.IO.FileMode]::Open)
$fileHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$fileHeader.Name = "datasetValuefile"
$fileHeader.FileName = "C:\temp\dataset_testing.csv"
$fileContent = [System.Net.Http.StreamContent]::new($FileStream)
$fileContent.Headers.ContentDisposition = $fileHeader
$multipartContent.Add($fileContent)

$stringHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$stringHeader.Name = "datasetname"
$stringContent = [System.Net.Http.StringContent]::new("mydatasetname")
$stringContent.Headers.ContentDisposition = $stringHeader
$multipartContent.Add($stringContent)

$body = $multipartContent

$response = Invoke-RestMethod -Method POST "$savUrl/uploadDatasetCSV" -Headers $headers -Body $body
$response | ConvertTo-Json

 

 

rushikeshvartak
All-Star
All-Star
  1. Get Dataset Values works with JSON

rushikeshvartak_0-1705363535728.png

You can upload csv file 


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.