Property folder in payload has a value that does not match schema

Viewed 63

the graph API request to create a folder in one drive is

POST /me/drive/root/children Content-Type: application/json

My code:

callMap = Map();
callMap.putAll({"name":"New Folder","folder":"{}","@microsoft.graph.conflictBehavior":"rename"});
headerMap = Map();
headerMap.putAll({"Content-Type":"application/json"});
r = invokeurl
[
url :"https://graph.microsoft.com/v1.0/me/drive/root/children"
type :POST
parameters:callMap.toString()
headers:headerMap
connection:"onedrive"
];
info r;

but gives the error "code": "BadRequest","message": "Property folder in payload has a value that does not match schema." Anyone have a solution?

2 Answers

The issue is that your definition of folder is "{}" (i.e. a string), when it should be {} (i.e. an object).

callMap = Map();
callMap.putAll({"name":"New Folder","folder":{ "@odata.type": "microsoft.graph.folder" },"@microsoft.graph.conflictBehavior":"rename"});
headerMap = Map();
headerMap.putAll({"Content-Type":"application/json"});
r = invokeurl
[
    url :"https://graph.microsoft.com/v1.0/me/drive/root/children"
    type :POST
    parameters:callMap.toString()
    headers:headerMap
    connection:"onedrive"
];
info r;
Related