Пример #1
0
        //gavdcodeend 29

        //gavdcodebegin 30
        static void SpCsRestGetAllMyPropertiesUserProfile(Uri webUri, string userName,
                                                          string password)
        {
            using (SPHttpClient client = new SPHttpClient(webUri, userName, password))
            {
                object myPayload   = null;
                string endpointUrl = webUri +
                                     "/_api/sp.userprofiles.peoplemanager/getmyproperties";
                var data = client.ExecuteJson(endpointUrl, HttpMethod.Get, myPayload);
                Console.WriteLine(data);
            }
        }
Пример #2
0
        //gavdcodeend 21

        //gavdcodebegin 22
        static void SpCsRestResultsSearchGET(Uri webUri, string userName,
                                             string password)
        {
            using (SPHttpClient client = new SPHttpClient(webUri, userName, password))
            {
                object myPayload   = null;
                string endpointUrl = webUri +
                                     "/_api/search/query?querytext='team'";
                var data = client.ExecuteJson(endpointUrl, HttpMethod.Get, myPayload);
                Console.WriteLine(data);
            }
        }
Пример #3
0
        //gavdcodeend 28

        //gavdcodebegin 29
        static void SpCsRestGetAllPropertiesUserProfile(Uri webUri, string userName,
                                                        string password)
        {
            using (SPHttpClient client = new SPHttpClient(webUri, userName, password))
            {
                string myUser = "******" +
                                ConfigurationManager.AppSettings["spUserName"].Replace("@", "%40");
                object myPayload   = null;
                string endpointUrl = webUri +
                                     "/_api/sp.userprofiles.peoplemanager/getpropertiesfor(@v)?@v='" +
                                     myUser + "'";
                var data = client.ExecuteJson(endpointUrl, HttpMethod.Get, myPayload);
                Console.WriteLine(data);
            }
        }
Пример #4
0
        //gavdcodeend 22

        //gavdcodebegin 23
        static void SpCsRestResultsSearchPOST(Uri webUri, string userName,
                                              string password)
        {
            using (SPHttpClient client = new SPHttpClient(webUri, userName, password))
            {
                object myPayload = new
                {
                    __metadata = new
                    {
                        type =
                            "Microsoft.Office.Server.Search.REST.SearchRequest"
                    },
                    Querytext  = "team",
                    RowLimit   = 20,
                    ClientType = "ContentSearchRegular"
                };
                string endpointUrl = webUri + "/_api/search/query";
                var    data        = client.ExecuteJson(endpointUrl, HttpMethod.Get, myPayload);
                Console.WriteLine(data);
            }
        }