Independentsoft
Any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> Update contact
The following example shows you how to update a contact.
C# example
using System; using System.Collections.Generic; using System.Threading.Tasks; using Independentsoft.Graph; using Independentsoft.Graph.Users; using Independentsoft.Graph.Contacts; namespace Sample { class Program { static async Task Main(string[] args) { try { GraphClient client = new GraphClient(); client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f"; client.Tenant = "independentsoft.onmicrosoft.com"; client.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; IList
contacts = await client.GetContacts(new UserId("info@independentsoft.onmicrosoft.com")); if (contacts.Count > 0) { Contact contact = new Contact(); contact.Id = contacts[0].Id; contact.JobTitle = "Senior Developer"; Contact updatedContact = await client.UpdateContact(contact, new UserId("info@independentsoft.onmicrosoft.com")); Console.WriteLine("JobTitle = " + updatedContact.JobTitle); } Console.Read(); } catch (GraphException ex) { Console.WriteLine("Error: " + ex.Code); Console.WriteLine("Message: " + ex.Message); Console.Read(); } } } }
VB example
Imports System.Collections.Generic Imports Independentsoft.Graph Imports Independentsoft.Graph.Users Imports Independentsoft.Graph.Contacts Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim task = New Task(AddressOf Run) task.Start() Console.Read() End Sub Shared Async Sub Run() Try Dim client As GraphClient = New GraphClient() client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f" client.Tenant = "independentsoft.onmicrosoft.com" client.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" Dim contacts As IList(Of Contact) = Await client.GetContacts(New UserId("info@independentsoft.onmicrosoft.com")) If contacts.Count > 0 Then Dim contact As Contact = New Contact() contact.Id = contacts(0).Id contact.JobTitle = "Senior Developer" Dim updatedContact As Contact = Await client.UpdateContact(contact, New UserId("info@independentsoft.onmicrosoft.com")) Console.WriteLine("JobTitle = " & updatedContact.JobTitle) End If Catch ex As GraphException Console.WriteLine("Error: " + ex.Code) Console.WriteLine("Error: " + ex.Message) Console.Read() End Try End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*