Independentsoft
Professional software libraries for developers
Home
Purchase
Support
Company
Contact
Graph C++
>
Tutorial
> Create list
The following example shows you how to create a new list in a site.
C++ example
#include
#include
#include "independentsoft/graph/graph_client.hpp" #include "independentsoft/graph/graph_exception.hpp" #include "independentsoft/graph/util.hpp" #include "independentsoft/graph/sites/list.hpp" #include "independentsoft/graph/sites/column_definition.hpp" #include "independentsoft/graph/sites/column.hpp" #include "independentsoft/graph/sites/text_column.hpp" #include "independentsoft/graph/sites/number_column.hpp" #include "independentsoft/graph/files/identity_set.hpp" #include "independentsoft/graph/files/identity.hpp" using namespace independentsoft::graph; using namespace independentsoft::graph::sites; int main() { try { GraphClient client; client.client_id = "63333333-209e-454e-b7bd-55a4d201270f"; client.tenant = "independentsoft.onmicrosoft.com"; client.client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; List list; list.display_name = "Books"; ColumnDefinition column1; column1.name = "Author"; column1.column = std::make_shared
(); ColumnDefinition column2; column2.name = "PageCount"; column2.column = std::make_shared
(); list.columns.push_back(column1); list.columns.push_back(column2); List createdList = sync_wait(client.create_list(list, "independentsoft.sharepoint.com,3333333-c666-4b40-c38")); std::cout << "Id: " << createdList.id << std::endl; std::cout << "CreatedTime: " << Util::to_universal_time(createdList.created_time) << std::endl; if (createdList.created_by) { if (createdList.created_by->user) { std::cout << "CreatedBy User: " << createdList.created_by->user->display_name << std::endl; } if (createdList.created_by->application) { std::cout << "CreatedBy Application: " << createdList.created_by->application->display_name << std::endl; } if (createdList.created_by->device) { std::cout << "CreatedBy Device: " << createdList.created_by->device->display_name << std::endl; } } } catch (const GraphException& ex) { std::cout << "Error: " << ex.code << std::endl; std::cout << "Message: " << ex.message << std::endl; } return 0; }
Need help? Ask our developers:
Name*
Email*
Message*