【发布时间】:2016-11-21 17:05:57
【问题描述】:
我正在尝试在 jsPlumb 中保存流程图(我使用的是 jsPlumb 工具包版)。我的保存功能如下所示:
jsPlumb.on(controls, "tap", function () {
toolkit.save({
url: "http://localhost:51987/api/Index/Save",
});
});
我的问题是我不知道如何在 jsPlumb 保存功能中将 请求标头设置为 application/json。
我收到“无法在浏览器控制台中加载资源:服务器响应状态为 415(不支持的媒体类型)”错误。
在 Fiddler 中检查请求:
HTTP/1.1 415 Unsupported Media Type Cache-Control: no-cache Pragma: 无缓存内容类型:应用程序/json; charset=utf-8 过期:-1 服务器:Microsoft-IIS/10.0 X-AspNet-版本:4.0.30319 X-SourceFiles: =?UTF-8?B?QzpccHJvamVjdHNcc3Bpa2VzXHBsdW1wLXNwaWtlXGpzUGx1bWJBUElcanNQbHVtYkFQSVxhcGlcSW5kZXhcU2F2ZQ==?= X-Powered-By:ASP.NET 日期:2016 年 11 月 21 日星期一 16:33:54 GMT 内容长度:910
{"Message":"请求实体的媒体类型'text/plain'不是 支持此资源。","ExceptionMessage":"否 MediaTypeFormatter 可用于读取类型的对象 来自具有媒体类型的内容的“JsPlumbViewModel” 'text/plain'。","ExceptionType":"System.Net.Http.UnsupportedMediaTypeException","StackTrace":" 在 System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent 内容,类型类型,IEnumerable
1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpContentExtensions.ReadAsAsync(HttpContent content, Type type, IEnumerable1 格式化程序,IFormatterLogger formatterLogger, CancellationToken cancelToken)\r\n 在 System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage 请求,类型类型,IEnumerable`1 格式化程序,IFormatterLogger formatterLogger, CancellationToken cancelToken)"}
【问题讨论】:
标签: javascript jsplumb