当前位置: 首页>>代码示例>>C#>>正文


C# RestRequest.AddParameter方法代码示例

本文整理汇总了C#中RestRequest.AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C# RestRequest.AddParameter方法的具体用法?C# RestRequest.AddParameter怎么用?C# RestRequest.AddParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RestRequest的用法示例。


在下文中一共展示了RestRequest.AddParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

    /// <summary>
    /// Retrieves a new token from Webtrends auth service
    /// </summary>
    public string Execute()
    {
        var builder = new JWTBuilder();
        var header = new JWTHeader
        {
            Type = "JWT",
            Algorithm = "HS256"
        };
        var claimSet = new JWTClaimSet
        {
            Issuer = clientId,
            Principal = clientId,
            Audience = audience,
            Expiration = DateTime.Now.ToUniversalTime().AddSeconds(30),
            Scope = scope
        };

        string assertion = builder.BuildAssertion(header, claimSet, clientSecret);
        var client = new RestClient(authUrl);
        var request = new RestRequest("token/", Method.POST);
        request.AddParameter("client_id", clientId);
        request.AddParameter("client_assertion", assertion);
        request.AddParameter("grant_type", "client_credentials");
        request.AddParameter("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer");

        var response = client.Execute(request).Content;
        return (string)JObject.Parse(response)["access_token"];
    }
开发者ID:MartyNeal,项目名称:Streams-OAuth-Libraries,代码行数:31,代码来源:TokenRequest.cs

示例2: ListTranscriptionsAsyncInternal

        private async Task<TranscriptionResult> ListTranscriptionsAsyncInternal(int? pageNumber, int? count)
        {
            var request = new RestRequest();
            request.Resource = "Accounts/{AccountSid}/Transcriptions.json";
            if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
            if (count.HasValue) request.AddParameter("PageSize", count.Value);

            var result = await ExecuteAsync(request, typeof(TranscriptionResult));
            return (TranscriptionResult)result;

        }
开发者ID:nkerkin,项目名称:twilio-csharp,代码行数:11,代码来源:Transcriptions.cs

示例3: AddNumberSearchParameters

 private void AddNumberSearchParameters(AvailablePhoneNumberListRequest options, RestRequest request)
 {
     if (options.AreaCode.HasValue()) request.AddParameter("AreaCode", options.AreaCode);
     if (options.Contains.HasValue()) request.AddParameter("Contains", options.Contains);
     if (options.Distance.HasValue) request.AddParameter("Distance", options.Distance);
     if (options.InLata.HasValue()) request.AddParameter("InLata", options.InLata);
     if (options.InPostalCode.HasValue()) request.AddParameter("InPostalCode", options.InPostalCode);
     if (options.InRateCenter.HasValue()) request.AddParameter("InRateCenter", options.InRateCenter);
     if (options.InRegion.HasValue()) request.AddParameter("InRegion", options.InRegion);
     if (options.NearLatLong.HasValue()) request.AddParameter("NearLatLong", options.NearLatLong);
     if (options.NearNumber.HasValue()) request.AddParameter("NearNumber", options.NearNumber);
 }
开发者ID:nkerkin,项目名称:twilio-csharp,代码行数:12,代码来源:AvailablePhoneNumbers.cs

示例4: ListAuthorizedConnectAppsAsyncInternal

        private async Task<AuthorizedConnectAppResult> ListAuthorizedConnectAppsAsyncInternal(int? pageNumber, int? count)
        {
            var request = new RestRequest();
            request.Resource = "Accounts/{AccountSid}/AuthorizedConnectApps.json";

            if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
            if (count.HasValue) request.AddParameter("PageSize", count.Value);

            var result = await ExecuteAsync(request, typeof(AuthorizedConnectAppResult));
            return (AuthorizedConnectAppResult)result;

        }
开发者ID:SnapMD,项目名称:twilio-csharp,代码行数:12,代码来源:AuthorizedConnectApps.cs

示例5: ListRecordingsAsyncInternal

        private async Task<RecordingResult> ListRecordingsAsyncInternal(string callSid, DateTimeOffset? dateCreated, int? pageNumber, int? count)
        {
            var request = new RestRequest();
            request.Resource = "Accounts/{AccountSid}/Recordings.json";

            if (callSid.HasValue()) request.AddParameter("CallSid", callSid);
            if (dateCreated.HasValue) request.AddParameter("DateCreated", dateCreated.Value.ToString("yyyy-MM-dd"));
            if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
            if (count.HasValue) request.AddParameter("PageSize", count.Value);

            var result = await ExecuteAsync(request, typeof(RecordingResult));
            return (RecordingResult)result;
        }
开发者ID:SnapMD,项目名称:twilio-csharp,代码行数:13,代码来源:Recordings.cs

示例6: CreateQueueAsyncInternal

        private async Task<Queue> CreateQueueAsyncInternal(string friendlyName, int maxSize)
        {
            var request = new RestRequest();
            request.Method = Method.POST;
            request.Resource = "Accounts/{AccountSid}/Queues.json";

            request.AddParameter("FriendlyName", friendlyName);
            request.AddParameter("MaxSize", maxSize);

            var result = await ExecuteAsync(request, typeof(Queue));
            return (Queue)result;

        }
开发者ID:nkerkin,项目名称:twilio-csharp,代码行数:13,代码来源:Queues.cs

示例7: ListOutgoingCallerIdsAsyncInternal

        private async Task<OutgoingCallerIdResult> ListOutgoingCallerIdsAsyncInternal(string phoneNumber, string friendlyName, int? pageNumber, int? count)
        {
            var request = new RestRequest();
            request.Resource = "Accounts/{AccountSid}/OutgoingCallerIds.json";

            if (phoneNumber.HasValue()) request.AddParameter("PhoneNumber", phoneNumber);
            if (friendlyName.HasValue()) request.AddParameter("FriendlyName", friendlyName);
            if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
            if (count.HasValue) request.AddParameter("PageSize", count.Value);

            var result = await ExecuteAsync(request, typeof(OutgoingCallerIdResult));
            return (OutgoingCallerIdResult)result;
        }
开发者ID:nkerkin,项目名称:twilio-csharp,代码行数:13,代码来源:OutgoingCallerIds.cs

示例8: ListApplicationsAsyncInternal

        private async Task<ApplicationResult> ListApplicationsAsyncInternal(string friendlyName, int? pageNumber, int? count)
		{
			var request = new RestRequest();
			request.Resource = "Accounts/{AccountSid}/Applications.json";

			if (friendlyName.HasValue()) request.AddParameter("FriendlyName", friendlyName);
			if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
			if (count.HasValue) request.AddParameter("PageSize", count.Value);

			//return Execute<ApplicationResult>(request);
            var result = await ExecuteAsync(request, typeof(ApplicationResult));
            return (ApplicationResult)result;

		}
开发者ID:SnapMD,项目名称:twilio-csharp,代码行数:14,代码来源:Applications.cs

示例9: ListNotificationsAsyncInternal

        private async Task<NotificationResult> ListNotificationsAsyncInternal(int? log, DateTimeOffset? messageDate, int? pageNumber, int? count)
        {
            var request = new RestRequest();
            request.Resource = "Accounts/{AccountSid}/Notifications.json";

            if (log.HasValue) request.AddParameter("Log", log);
            if (messageDate.HasValue) request.AddParameter("MessageDate", messageDate.Value.ToString("yyyy-MM-dd"));
            if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
            if (count.HasValue) request.AddParameter("PageSize", count.Value);

            var result = await ExecuteAsync(request, typeof(NotificationResult));
            return (NotificationResult)result;

        }
开发者ID:SnapMD,项目名称:twilio-csharp,代码行数:14,代码来源:Notifications.cs

示例10: ListSmsMessagesAsyncInternal

        private async Task<SmsMessageResult> ListSmsMessagesAsyncInternal(string to, string from, DateTimeOffset? dateSent, int? pageNumber, int? count)
		{
			var request = new RestRequest();
			request.Resource = "Accounts/{AccountSid}/SMS/Messages.json";

			if (to.HasValue()) request.AddParameter("To", to);
			if (from.HasValue()) request.AddParameter("From", from);
			if (dateSent.HasValue) request.AddParameter("DateSent", dateSent.Value.ToString("yyyy-MM-dd"));
			if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
			if (count.HasValue) request.AddParameter("PageSize", count.Value);

            var result = await ExecuteAsync(request, typeof(SmsMessageResult));
            return (SmsMessageResult)result;

		}
开发者ID:nkerkin,项目名称:twilio-csharp,代码行数:15,代码来源:Sms.cs

示例11: GET_with_multiple_instances_of_same_key

        public void GET_with_multiple_instances_of_same_key()
        {
            var request = new RestRequest("v1/people/~/network/updates", Method.GET);
            request.AddParameter("type", "STAT");
            request.AddParameter("type", "PICT");
            request.AddParameter("count", "50");
            request.AddParameter("start", "50");

            var client = new RestClient("http://api.linkedin.com");

            var expected = new Uri("http://api.linkedin.com/v1/people/~/network/updates?type=STAT&type=PICT&count=50&start=50");
            var output = client.BuildUri(request);

            Assert.Equal(expected, output);
        }
开发者ID:ryno1234,项目名称:RestSharp,代码行数:15,代码来源:UrlBuilderTests.cs

示例12: AddApplicationAsyncInternal

        private async Task<Application> AddApplicationAsyncInternal(string friendlyName, ApplicationOptions options)
		{
			var request = new RestRequest();
            request.Method = Method.POST;
			request.Resource = "Accounts/{AccountSid}/Applications.json";
			
			Require.Argument("FriendlyName", friendlyName);
			Validate.IsValidLength(friendlyName, 64);
			request.AddParameter("FriendlyName", friendlyName);

			// some check for null. in those cases an empty string is a valid value (to remove a URL assignment)
			if (options != null)
			{
				if (options.VoiceUrl != null) request.AddParameter("VoiceUrl", options.VoiceUrl);
				if (options.VoiceMethod.HasValue()) request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
				if (options.VoiceFallbackUrl != null) request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
				if (options.VoiceFallbackMethod.HasValue()) request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
				if (options.VoiceCallerIdLookup.HasValue) request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
				if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
				if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
				if (options.SmsUrl != null) request.AddParameter("SmsUrl", options.SmsUrl);
				if (options.SmsMethod.HasValue()) request.AddParameter("SmsMethod", options.SmsMethod.ToString());
				if (options.SmsFallbackUrl != null) request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
				if (options.SmsFallbackMethod.HasValue()) request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
			}

            var result = await ExecuteAsync(request, typeof(Application));
            return (Application)result;
		}
开发者ID:SnapMD,项目名称:twilio-csharp,代码行数:29,代码来源:Applications.cs

示例13: TestMultipleRequests

        public async Task TestMultipleRequests(Type factoryType)
        {
            using (var client = new RestClient("http://httpbin.org/")
            {
                HttpClientFactory = CreateClientFactory(factoryType, false),
            })
            {
                {
                    var request = new RestRequest("post", Method.POST);
                    request.AddParameter("param1", "param1");

                    var response = await client.Execute<HttpBinResponse>(request);
                    Assert.NotNull(response.Data);
                    Assert.NotNull(response.Data.Form);
                    Assert.True(response.Data.Form.ContainsKey("param1"));
                    Assert.Equal("param1", response.Data.Form["param1"]);
                }

                {
                    var request = new RestRequest("post", Method.POST);
                    request.AddParameter("param1", "param1+");

                    var response = await client.Execute<HttpBinResponse>(request);
                    Assert.NotNull(response.Data);
                    Assert.NotNull(response.Data.Form);
                    Assert.True(response.Data.Form.ContainsKey("param1"));
                    Assert.Equal("param1+", response.Data.Form["param1"]);
                }
            }
        }
开发者ID:yuleyule66,项目名称:restsharp.portable,代码行数:30,代码来源:OtherTests.cs

示例14: MultipartFormData_WithParameterAndFile_Async

        public void MultipartFormData_WithParameterAndFile_Async()
        {
            const string baseUrl = "http://localhost:8888/";

            using (SimpleServer.Create(baseUrl, EchoHandler))
            {
                RestClient client = new RestClient(baseUrl);
                RestRequest request = new RestRequest("/", Method.POST)
                                      {
                                          AlwaysMultipartFormData = true
                                      };
                DirectoryInfo directoryInfo = Directory.GetParent(Directory.GetCurrentDirectory())
                                                       .Parent;

                if (directoryInfo != null)
                {
                    string path = Path.Combine(directoryInfo.FullName,
                        "Assets\\TestFile.txt");

                    request.AddFile("fileName", path);
                }

                request.AddParameter("controlName", "test", "application/json", ParameterType.RequestBody);

                Task task = client.ExecuteTaskAsync(request)
                                  .ContinueWith(x =>
                                                {
                                                    Assert.AreEqual(this.expectedFileAndBodyRequestContent, x.Result.Content);
                                                });

                task.Wait();
            }
        }
开发者ID:CL0SeY,项目名称:RestSharp,代码行数:33,代码来源:MultipartFormDataTests.cs

示例15: CheckMessageBodyXmlWithAttributes

 public void CheckMessageBodyXmlWithAttributes()
 {
     var request = new RestRequest("/test?test1={test1}", HttpMethod.Get) {ContentType = ContentTypes.Xml};
     request.AddParameter(new PhoneNumber("1", "514-9700"));
     var body = request.GetRequestBody();
     Assert.IsNotNull(body);
     Assert.AreEqual("<PhoneNumber ID=\"1\">\r\n  <Call />\r\n  <Calls />\r\n  <Number>514-9700</Number>\r\n</PhoneNumber>", body);
 }
开发者ID:rajeshwarn,项目名称:PortableRest,代码行数:8,代码来源:CoreTests.cs


注:本文中的RestRequest.AddParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。