我正在尝试使用C#中的Webclient将Json中的多个参数解析为RESTful服务。我保留了400错误请求的错误。它在我传递一个参数但在我尝试传递多个时不起作用时有效,请指教:下面的代码在我的Test Methjod中查询RESTful端点
AuthToken = GetAuthToken();
var wcProxy = new WebClient();
wcProxy.Headers[HttpRequestHeader.Authorization] = "Basic " + AuthToken;
wcProxy.Headers[HttpRequestHeader.Accept] = "application/json";
wcProxy.Headers[HttpRequestHeader.ContentType] = "application/json";
var vm = new ValidateBankAccountCriteria
{
AccountNumber = "62294444915",
BankAccountType = BankAccountType.CurrentAccount,
BranchCode = "254605"
};
string payload = JsonConvert.SerializeObject(vm);
var payloaded = System.Text.ASCIIEncoding.ASCII.GetBytes(payload);
Byte[] returnData = wcProxy.UploadData(new Uri(wsUrl + "ValidateBankAccount/"), "POST", payloaded);
var results = Encoding.ASCII.GetString(returnData);
Assert.IsTrue(results.Contains("NEDBANK"), "call failed");