static void Main(string[] args) { var apiClient = new HttpClient(); // apiClient.BaseAddress = new System.Uri("http://localhost:6357"); apiClient.BaseAddress = new System.Uri("http://localhost:18193"); var command = new ModifyCooperatorBasic { CooperatorID = "52b007cd9a37601480b6d5e6", Name = "ivan", Type = 0, Remark = "" }; var task = apiClient.DoCommand(command); var result = task.Result.Content.ReadAsStringAsync().Result; Console.Write(result); }
public Task<ApiResult> Put([FromBody]ICommand command) { if (ModelState.IsValid) { HttpClient client = new HttpClient(); client.BaseAddress = new Uri(string.Format("{0}://{1}/api/command", Request.RequestUri.Scheme, Request.RequestUri.Authority)); return client.DoCommand<ApiResult>(command, null); } else { return Task.Factory.StartNew<ApiResult>(() => new ApiResult { ErrorCode = ErrorCode.CommandInvalid, Message = string.Join(",", ModelState.Values .SelectMany(v => v.Errors .Select(e => e.ErrorMessage))) }); } }