Independentsoft
Professional software libraries for developers
Home
Purchase
Support
Company
Contact
Graph C++
>
Tutorial
> Get list including items
The following example shows you how to get a list including list items.
C++ example
#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/list_item.hpp" #include "independentsoft/graph/sites/list_item_field.hpp" #include "independentsoft/graph/sites/list_property_name.hpp" #include "independentsoft/graph/query_options/query.hpp" using namespace independentsoft::graph; using namespace independentsoft::graph::sites; using namespace independentsoft::graph::query_options; int main() { try { GraphClient client; client.client_id = "6333333-209e-454e-b7bd-55a4d201270f"; client.tenant = "independentsoft.onmicrosoft.com"; client.username = "info@independentsoft.onmicrosoft.com"; client.password = "password"; Query query; query.expand.push_back(ListPropertyName::items); List list = sync_wait(client.get_list("independentsoft.sharepoint.com,333333333-c666-4b40-bcd4-d771fb97ae69,73b98e9e-5749-407a-82b1-31d82fb30539", "333333333-2a3d-4235-9305-9f8bd6c7300a", query)); std::cout << "List Id: " << list.id << std::endl; std::cout << "List Name: " << list.name << std::endl; std::cout << "List DisplayName: " << list.display_name << std::endl; std::cout << "List CreatedTime: " << Util::to_universal_time(list.created_time) << std::endl; std::cout << "List WebUrl: " << list.web_url << std::endl; std::cout << "-----------------------------------------------------------------" << std::endl; for (const ListItem& item : list.items) { std::cout << "Item Id: " << item.id << std::endl; std::cout << "Item Name: " << item.name << std::endl; std::cout << "-----------------------------------------------------------------" << std::endl; for (const ListItemField& field : item.fields) { std::cout << "Field Name: " << field.name << std::endl; std::cout << "Field Value: " << field.value << std::endl; std::cout << "-----------------------------------------------------------------" << 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*