Example #1
0
        public Tuple <string, string> SendGraphRequest()
        {
            AdAppToken adToken = new AdAppToken();

            if (Registration == TypeRegistration.Application)
            {
                adToken = GetAzureTokenApplication();
            }
            else if (Registration == TypeRegistration.Delegation)
            {
                adToken = GetAzureTokenDelegation();
            }

            if (adToken != null)
            {
                List <HeaderConfig> myHeadersList       = new List <HeaderConfig>();
                HeaderConfig        authorizationHeader = new HeaderConfig
                {
                    HeaderTitle = "Authorization",
                    HeaderValue = adToken.token_type + " " + adToken.access_token
                };
                myHeadersList.Add(authorizationHeader);
                Headers = myHeadersList;

                return(SendGraphRequestInternal());
            }
            else
            {
                Tuple <string, string> tplReturn = new Tuple <string, string>
                                                       ("Error", string.Empty);
                return(tplReturn);
            }
        }
Example #2
0
        //gavdcodebegin 07
        static void UpdateChannelApp()
        {
            string graphQuery = "https://graph.microsoft.com/v1.0/teams/" +
                                "5b409eec-a4ae-4f04-a354-0434c444265d/channels/" +
                                "19:[email protected]";

            string myBody = "{ \"description\": \"Channel Description Updated\" }";

            List <HeaderConfig> myHeadersList = new List <HeaderConfig>();
            HeaderConfig        myHeaderMat   = new HeaderConfig
            {
                HeaderTitle = "IF-MATCH",
                HeaderValue = "*"
            };

            myHeadersList.Add(myHeaderMat);

            RestGraphClient myClient = new RestGraphClient
            {
                ClientID     = ConfigurationManager.AppSettings["ClientIdApp"],
                ClientSecret = ConfigurationManager.AppSettings["ClientSecretApp"],
                TenantName   = ConfigurationManager.AppSettings["TenantName"],
                EndPoint     = graphQuery,
                Method       = HttpVerb.PATCH,
                ContentType  = "application/json",
                Headers      = myHeadersList,
                PostData     = myBody,
                Registration = TypeRegistration.Application
            };

            Tuple <string, string> resultText = myClient.SendGraphRequest();

            Console.WriteLine(resultText.Item1);
            Console.WriteLine(resultText.Item2);
        }