本文整理汇总了C#中RestSharp.RestClient.Put方法的典型用法代码示例。如果您正苦于以下问题:C# RestClient.Put方法的具体用法?C# RestClient.Put怎么用?C# RestClient.Put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RestSharp.RestClient
的用法示例。
在下文中一共展示了RestClient.Put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var appName = string.Empty;
var hostName = string.Empty;
var help = false;
var p = new OptionSet
{
{"app=", v => appName = v},
{"host=", v => hostName = v},
{"h|?|help", v => help = v != null},
};
p.Parse(args);
if (help || string.IsNullOrWhiteSpace(appName) || string.IsNullOrWhiteSpace(hostName))
{
p.WriteOptionDescriptions(Console.Out);
return;
}
var restClient = new RestClient("http://" + hostName + ":9000");
var request = new RestRequest("/api/v1/apps/" + appName, Method.PUT);
request.RequestFormat = DataFormat.Json;
request.AddBody(new { @null = string.Empty });
var response = restClient.Put(request);
if (response.StatusCode == HttpStatusCode.Created)
{
Console.WriteLine("'{0}' deployment started remotely on '{1}'.", appName, hostName);
}
}
示例2: Run
public IRestResponse Run(Step step, ScenarioContext context)
{
var apiPostStep = (ApiPutStep)step;
var client = new RestClient(apiPostStep.Host);
var restRequest = BuildRequest(apiPostStep);
restRequest.AddBody(apiPostStep.RequestPayload);
return client.Put(restRequest);
}
示例3: Put
public ApiStepResult Put(Guid stepId, string host, string resource, string requestPayload)
{
DateTime start = DateTime.Now;
var client = new RestClient(host);
var restRequest = new RestRequest(resource);
restRequest.RequestFormat = DataFormat.Json;
restRequest.AddBody(requestPayload);
var restResponse = client.Put(restRequest);
TimeSpan span = DateTime.Now - start;
return new ApiStepResult(stepId, restResponse.StatusCode, restResponse.Content, _timeProvider.Now(),
span.TotalMilliseconds);
}
示例4: UpdateRatings
static void UpdateRatings(string directory, RestClient rest)
{
foreach(var file in Directory.GetFiles(directory)) {
var fileInfo = new FileInfo (file);
var bggId = fileInfo.Name.Replace (".json", "");
var req = new RestRequest ("/topic/boardgames/bgg/" + bggId + "/rating/update");
Console.WriteLine (req.Resource);
var resp = rest.Put (req);
Console.WriteLine (resp.StatusCode);
Console.WriteLine (resp.Content);
Console.WriteLine ();
}
}
示例5: SyncGameInfo
static void SyncGameInfo(string directory, RestClient rest)
{
foreach (var file in Directory.GetFiles (directory)) {
var info = new FileInfo (file);
var request = new RestRequest ("/topic/boardgames/bgg/" + info.Name.Replace (".json", ""), Method.PUT);
Console.WriteLine (request.Resource);
request.AddParameter ("text/json", File.ReadAllText (file), ParameterType.RequestBody);
Console.WriteLine ("Putting json from " + file);
var resp = rest.Put (request);
Console.WriteLine (resp.StatusCode);
Console.WriteLine (resp.Content);
}
}
示例6: SyncRatings
static void SyncRatings(string directory, RestClient rest)
{
foreach(var file in Directory.GetFiles(directory)) {
var fileInfo = new FileInfo (file);
var bggId = fileInfo.Name.Replace (".json", "");
foreach (var line in File.ReadLines(file)) {
var req = new RestRequest ("/topic/boardgames/bgg/" + bggId + "/rating");
req.AddParameter ("text/json", line, ParameterType.RequestBody);
Console.WriteLine (req.Resource);
var resp = rest.Put (req);
Console.WriteLine (resp.StatusCode);
Console.WriteLine (resp.Content);
Console.WriteLine ();
if (resp.StatusCode == System.Net.HttpStatusCode.InternalServerError) {
break;
}
}
}
}