本文整理汇总了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"];
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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"]);
}
}
}
示例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();
}
}
示例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);
}