Creating folders on OneDrive

Oct 28, 2014 at 4:44 PM
Hi All,

Can somebody show me a working C++ code about creating a folder in OneDrive?

My app is already logs in and uploads/downloads app data by using the web::live::live_client class, but I don't have a clue how to create a folder.

As far as I know, I should use a post command, but I don't know how to use it to create a folder, named "my_test_folder" in onedrive.

Thank you.
Oct 28, 2014 at 7:22 PM
Hi perneky,

Looking at the docs, it says
To create a new Folder resource, make a POST request to /FOLDER_ID. Pass the name and description attributes in the request body, as shown here.
   "name": "Informative Spreadsheets",
   "description": "A folder full of useful data visualizations."
The folder is created as a child of the folder that is specified in the request URL.
Marked as answer by roschuma on 11/3/2014 at 2:03 PM
Oct 29, 2014 at 4:16 PM
Hi roschuma,

Thank you for the info. The format json post is clear, and now I figured out how to create that query by using the C++ framework. For the reference, i goes like this:

std::vector< std::pair< ::utility::string_t, web::json::value > > fields;
fields.push_back( std::pair< ::utility::string_t, web::json::value >( L"name", web::json::value( L"Folder name" ) ) );
fields.push_back( std::pair< ::utility::string_t, web::json::value >( L"description", web::json::value( L"Folder desc." ) ) );
return liveClient->post( L"me/skydrive", web::json::value::object( fields ) );

This part of the framework is really underdocumented.

Thank you for your help.
Oct 29, 2014 at 7:01 PM
Hi perneky,

FYI the live_client class isn't actually part of the C++ Rest SDK. It is just a sample about what can be created utilizing.