向 API 发送 POST 请求时出错(无法发送具有此动词类型的正文)

Error while sending POST request to API (Cannot send a body with this verb type)

当我尝试请求 API 时,我总是遇到此错误。 关于 api 的一些细节:方法是 POST 并且参数也是正确的(当我在 postman 上尝试时,没问题)

这是我的代码:

JavaScriptSerializer js = new JavaScriptSerializer();
using (WebClient client = new WebClient())
{
    foreach (var ad in documents)
    {

        var doc = js.Serialize(ad);
        var json = "{\"Message\":\"" + doc + "\"}";

        var response =
            client.UploadValues("apiUrl", new NameValueCollection()
            {
                {"json", json}
            });
    }
}

我了解到 UploadValues 默认为 POST。此代码在一个简单的控制台应用程序中调用。知道为什么我会收到此错误吗?

这是一段有效的代码:

var doc = JsonConvert.SerializeObject(message);    
var stringContent = new StringContent(
        message,
        UnicodeEncoding.UTF8,
        "application/json");

HttpClient client = new HttpClient();                

client.PostAsync("apiUrl", stringContent);