问题描述
如何使用request.AddBody方法在 VB.Net中将主体参数添加到其余API请求?
下面是我在C#中的代码,但我想在 VB.Net
RestClient client = new RestClient("URL of API service");
RestRequest request = new RestRequest("/MethodName",Method.POST);
request.AddHeader("Accept","application/json");
request.RequestFormat = DataFormat.Json;
request.AddBody(new SampleClass
{
Property1 = Guid.NewGuid().ToString(),Property2 = "",Property3 = 123
});
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
//Deserialize JSON content string to object
SampleResponse responSEObj = JsonConvert.DeserializeObject<SampleResponse>(response.Content);
if (responSEObj == null)
{
throw new Exception("Error msg");
}
if (responSEObj.ResultList != null)
{
rVal = responSEObj.ResultList.ToList();
}
else
{
throw new exception("Error in API");
}
}
如何在VB中添加以上代码,尤其是类中的request.AddBody内容?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)