我正在使用 JQuery 3 将数据发布到 API,如下所示:
$.post({ url: "api/questions", data: { content: "Content" }, dataType: "json" })
.done(function (data, status, xhr) {
console.log(message);
})
.fail(function (xhr, status, error) {
console.log(error);
})
当我运行它时,我收到以下错误:
Unsupported Media Type
我不确定为什么会这样。我使用 PostMan 测试了我的 API,以发送带有以下正文的 Post 请求:
{
content: "Content"
}
它工作得很好......我错过了什么?