本文整理汇总了C#中RestSharp.Portable.RestRequest.AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C# RestRequest.AddParameter方法的具体用法?C# RestRequest.AddParameter怎么用?C# RestRequest.AddParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RestSharp.Portable.RestRequest
的用法示例。
在下文中一共展示了RestRequest.AddParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Login
public bool Login(string password)
{
var request = new RestRequest(ApiUris.Login, HttpMethod.Post);
request.AddParameter("DeviceId", _deviceId);
request.AddParameter("Password", password);
_sessionId = Execute<string>(request);
return _sessionId != null;
}
示例2: GetMembers
public async Task<List<AthleteSummary>> GetMembers(int id, int page, int itemsPerPage)
{
var request = new RestRequest(EndPoint + "/{id}/members", Method.GET);
request.AddParameter("id", id, ParameterType.UrlSegment);
if (page != 0)
request.AddParameter("page", page);
if (itemsPerPage != 0)
request.AddParameter("per_page", itemsPerPage);
var response = await _client.RestClient.Execute<List<AthleteSummary>>(request);
return response.Data;
}
示例3: CreateChunkedUploadRequest
public RestRequest CreateChunkedUploadRequest(ChunkedUpload upload, byte[] fileData)
{
var request = new RestRequest("{version}/chunked_upload", HttpMethod.Put);
request.AddParameter("version", _version, ParameterType.UrlSegment);
if (upload.HasUploadId)
{
request.AddParameter("upload_id", upload.UploadId, ParameterType.UrlSegment);
request.AddParameter("offset", upload.Offset, ParameterType.UrlSegment);
}
request.AddParameter("file", fileData, ParameterType.RequestBody);
return request;
}
示例4: GetAthleteActivities
private async Task<List<ActivitySummary>> GetAthleteActivities(DateTime before, DateTime after, int page, int itemsPerPage)
{
var request = new RestRequest("/api/v3/athlete/activities");
if (before != DateTime.MinValue)
request.AddQueryParameter("before", before.GetSecondsSinceUnixEpoch());
if (after != DateTime.MinValue)
request.AddQueryParameter("after", after.GetSecondsSinceUnixEpoch());
if (page != 0)
request.AddParameter("page", page);
if (itemsPerPage != 0)
request.AddParameter("per_page", itemsPerPage);
var response = await _client.RestClient.Execute<List<ActivitySummary>>(request);
return response.Data;
}
示例5: Get
public async Task<Club> Get(int id)
{
var request = new RestRequest(EndPoint + "/{id}", Method.GET);
request.AddParameter("id", id, ParameterType.UrlSegment);
var response = await _client.RestClient.Execute<Club>(request);
return response.Data;
}
示例6: Search
public async Task<Result<Address>> Search(string search, string latitude, string longitude)
{
using (var client = new RestClient(_client.BaseAddress))
{
var request = new RestRequest("search", HttpMethod.Get);
request.AddParameter("address", search);
request.AddParameter("numberpage", numberpage);
request.AddParameter("skippage", skippage);
client.IgnoreResponseStatusCode = true;
var result = await client.Execute<List<Address>>(request);
return new Result<Address>() { Success = true, Values = result.Data };
}
}
示例7: GetEfforts
private async Task<IEnumerable<SegmentEffort>> GetEfforts(int segmentId, int? athleteId, DateTime? startDateLocal, DateTime? endDateLocal, int? page, int? perPage)
{
var request = new RestRequest(EndPoint + "/" + segmentId + "/all_efforts", Method.GET);
if (athleteId != null)
request.AddParameter("athlete_id", athleteId.Value);
if (startDateLocal != null)
request.AddParameter("start_date_local", startDateLocal);
if (endDateLocal != null)
request.AddParameter("end_date_local", endDateLocal);
if (page != null)
request.AddParameter("page", page);
if (perPage != null)
request.AddParameter("per_page", perPage);
var response = await _client.RestClient.Execute<SegmentEffort[]>(request);
return response.Data;
}
示例8: CreateAccountInfoRequest
public RestRequest CreateAccountInfoRequest()
{
var request = new RestRequest("{version}/account/info", HttpMethod.Get);
request.AddParameter("version", _version, ParameterType.UrlSegment);
return request;
}
示例9: CreateAccessTokenRequest
public RestRequest CreateAccessTokenRequest()
{
var request = new RestRequest("{version}/oauth/access_token", HttpMethod.Get);
request.AddParameter("version", _version, ParameterType.UrlSegment);
return request;
}
示例10: Register
public int Register(string password)
{
var request = new RestRequest("api/Register", HttpMethod.Post);
request.AddParameter("DeviceId", _deviceId);
request.AddParameter("Password", password);
return Execute<int>(request);
}
示例11: Get
public async Task<Activity> Get(long activityId, bool includeAllEfforts = true)
{
var request = new RestRequest(EndPoint + "/{id}", Method.GET);
request.AddParameter("id", activityId, ParameterType.UrlSegment);
var response = await _client.RestClient.Execute<Activity>(request);
return response.Data;
}
示例12: Explore
public async Task<List<SegmentSummary>> Explore(LatLng southWest, LatLng northEast, ActivityType activityType = ActivityType.Ride)
{
var request = new RestRequest(EndPoint + "/explore", Method.GET);
request.AddParameter("bounds",
string.Format("{0},{1},{2},{3}", southWest.Latitude.ToString(CultureInfo.InvariantCulture), southWest.Longitude.ToString(CultureInfo.InvariantCulture),
northEast.Latitude.ToString(CultureInfo.InvariantCulture), northEast.Longitude.ToString(CultureInfo.InvariantCulture)));
var response = await _client.RestClient.Execute<SegmentCollection>(request);
return response.Data.Segments;
}
示例13: UnShim
/// <summary>
/// Converts this instance to an IRestRequest
/// </summary>
internal IRestRequest UnShim()
{
var req = new RestRequest(this.Resource, Unshim(this.Method));
if (!this.CsrfToken.IsBlank())
req.AddHeader("X-CSRF-Token", this.CsrfToken);
if (this.Body != null)
req.AddJsonBody(this.Body);
if (this.Cookies != null)
foreach (var cookie in this.Cookies)
req.AddParameter(cookie.Key, cookie.Value, ParameterType.Cookie);
if (this.Parameters != null)
{
//if (this.Parameters.Count > 0)
// req.AddHeader("Content-Type", "application/x-www-form-urlencoded");
foreach (var param in this.Parameters)
req.AddParameter(param.Key, param.Value, ParameterType.RequestBody);
}
//later: try this for attaching files to nodes:
//req.ContentCollectionMode = ContentCollectionMode.MultiPartForFileParameters;
//req.RequestFormat = DataFormat.Json; <--- Drupal ignores this
//if (this.Attachment != null)
//{
// req.AddFile(this.Attachment.Name,
// this.Attachment.Stream,
// this.Attachment.Name,
// MediaTypeHeaderValue.Parse("multipart/form-data"));
// req.AddParameter("field_name", "field_private_file");//hack: hard-code!
// //req.AddParameter("files[files]", "@" + this.Attachment.Name);
//}
return req;
}
示例14: Login
public async Task<Result<string>> Login(string email, string password)
{
using (var client = new RestClient(_client.BaseAddress))
{
var request = new RestRequest("oauth/token", HttpMethod.Post);
request.AddParameter("username", email);
request.AddParameter("password", password);
request.AddParameter("grant_type", "password");
request.AddParameter("client_id", this.client_id);
request.AddParameter("client_secret", this.secret_id);
client.IgnoreResponseStatusCode = true;
var result = await client.Execute<Users>(request);
if (result.StatusCode == HttpStatusCode.Unauthorized)
{
return new Result<string>()
{
Success = false,
Value = "Email e/ou Senha inválidos..."
};
}
else if (result.StatusCode == HttpStatusCode.InternalServerError)
{
return new Result<string>()
{
Success = false,
Value = "Error..."
};
}
else
{
return new Result<string>()
{
Success = true,
Value = result.Data.access_token
};
}
}
}
示例15: GetPublicationSummaries
public string GetPublicationSummaries(List<string> publicationIds)
{
var restClient = new RestClient(ServiceURLs.ESummaryBaseURL);
var restRequest = new RestRequest();
restRequest.AddParameter("db", databaseName, ParameterType.QueryString);
restRequest.AddParameter("retmode", "json", ParameterType.QueryString);
restRequest.AddParameter("rettype", "abstract", ParameterType.QueryString);
restRequest.AddParameter("id", string.Join(", ", publicationIds.ToArray()), ParameterType.QueryString);
restRequest.AddParameter("version", "2.0", ParameterType.QueryString);
// Get the response.
var waitTime = PubMedThrottler.GetWaitTime();
Thread.Sleep(waitTime);
//TODO: Fix mapping from json or xml;
var response = restClient.Execute(restRequest).Result;
return response.ToString();
}