How do I have to write my json-data so I can import it into a dataset?
Through postman (POST {{url}}/api//dataset/importjson/1) I try to post json-data into a dataset, but as a response I get:
{
"error": {
"message": "Malformed JSON body, rows and uniqueKeys are required",
"code": 422,
"data": []
}
}
This couldn’t easily be modelled with Swagger (as far as I could see anyway).
The API expects a JSON formatted object, but needs some extra information as per the comment. In particular we need to know the uniqueKeys.
{
uniqueKeys: [col1],
rows: [{
col1: value1
}]
}
I’d imagine your JSON could be changed to:
{
"uniqueKeys":[
"petName"
],
"rows":[
{
"petName":"Buffy",
"ownerName":"Hassum Harrod",
"aptDate":"2016-06-20 15:30",
"aptNotes":"This Chihuahua has not eaten for three days and is lethargic"
},
{
"petName":"Spot",
"ownerName":"Constance Smith",
"aptDate":"2016-06-24 08:30",
"aptNotes":"This German Shepherd is having some back pain"
},
{
"petName":"Goldie",
"ownerName":"Barot Bellingham",
"aptDate":"2016-06-22 15:50",
"aptNotes":"This Goldfish has some weird spots in the belly"
},
{
"petName":"Mitten",
"ownerName":"Hillary Goldwyn",
"aptDate":"2016-06-21 9:15",
"aptNotes":"Cat has excessive hairballs"
}
]
}
I want to use the API to import a JSON object into a dataset by using /dataset/importjson/{dataSetId}.
My dataset (ID=2) exists of one column “Col1”. I want to add “value1” to the dataset with the PHP-code below.
$provider = new \Xibo\OAuth2\Client\Provider\Xibo([
‘clientId’ => ‘’, // The client ID assigned to you by the provider
’clientSecret’ => ‘’, // The client password assigned to you by the provider
’redirectUri’ => ‘’,
‘baseUrl’ => ‘’
]);
$xiboClient = new \Xibo\OAuth2\Client\Provider\XiboEntityProvider($provider);
But the last rule gives the following error:
PHP Fatal error: Uncaught exception ‘Xibo\OAuth2\Client\Exception\XiboApiException’ with message '{
“error”: {
“message”: “Missing JSON Body”,
“code”: 422,
“data”: []
}
}
It’s not clear for me how I need to send the JSON-body with the post-method of the xiboClient. Can you help me? Thans a lot.