skip to Main Content

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


  1. Chosen as BEST ANSWER
    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;
    

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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search