Independentsoft
Professional software libraries for developers
Home
Purchase
Support
Company
Contact
Graph C++
>
Tutorial
> Create contact
The following example shows you how to create a new contact.
C++ example
#include
#include "independentsoft/graph/graph_client.hpp" #include "independentsoft/graph/graph_exception.hpp" #include "independentsoft/graph/email_address.hpp" #include "independentsoft/graph/phone.hpp" #include "independentsoft/graph/phone_type.hpp" #include "independentsoft/graph/contacts/contact.hpp" using namespace independentsoft::graph; using namespace independentsoft::graph::contacts; int main() { try { GraphClient client; client.client_id = "67cb3333-209e-454e-b7bd-55a4d201270f"; client.tenant = "independentsoft.onmicrosoft.com"; client.username = "info@independentsoft.onmicrosoft.com"; client.password = "password"; Contact contact; contact.display_name = "Alice Smith"; contact.given_name = "Alice"; contact.surname = "Smith"; contact.title = "Dr"; contact.job_title = "Software developer"; contact.office_location = "Berlin"; contact.email_addresses.push_back(EmailAddress("alice@independentsoft.onmicrosoft.com")); contact.phones.push_back(Phone("555-666-777", PhoneType::Business)); contact.phones.push_back(Phone("555-111-777", PhoneType::Mobile)); Contact createdContact = sync_wait(client.create_contact(contact)); std::cout << "Id = " << createdContact.id << 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*