我的控制器中有以下 Web api 方法
public HttpResponseMessage PostUpdateCardStatus(CardholderRequest cardholderRequest)
{
var cardId = cardholderRequest.CardId;
switch (cardholderRequest.Action)
{
case "Enable":
break;
case "Disable":
break;
}
var cardholderResponse = new CardholderResponse(cardholderRequest.RequestId)
{
Status = "OK"
};
var response = Request.CreateResponse<CardholderResponse>(HttpStatusCode.OK, cardholderResponse);
return response;
}
这就是我从 .NET 控制台应用程序调用它的方式
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:55208/");
var request = new CardholderRequest()
{
RequestId = Guid.NewGuid().ToString(),
CardId = "123456",
Action = "Enable",
LoginId = "tester",
Password = "tester",
};
var response = client.PostAsJsonAsync("api/cardholders", request).Result;
if (response.IsSuccessStatusCode)
{
var cardholderResponse = response.Content.ReadAsAsync<CardholderResponse>().Result;
}
如何使用 VBScript 进行相同的调用?
我试过谷歌搜索,但我没有遇到任何从 VB 脚本调用 web api 方法的可靠示例。
我的 web api 方法是否支持来自 VBScript 的调用?还是我需要一些调整?