我尝试使用AngularJS资源为我的Titan Server 0.4.4图表添加边缘。资源如下所示:
'use strict';
angular.module('storymapApp').factory('edgeResource', function ($resource) {
var EdgeResource = $resource('http://localhost:8182/graphs/graph/edges?_outV=:outId&label=:label&_inV=:inId', {outId: "@outId", inId: "@inId", label: "@label"}, {
update: {method: 'PUT', isArray: false},
outedge: {method: 'POST',
transformResponse: function(data, headers){
// deserialize the JSON response string
data = angular.fromJson(data);
data = data.results;
return data;
},
isArray: true}
});
return EdgeResource;
});
此代码生成如下的POST:
http://localhost:8182/graphs/graph/edges?_outV=120028&label=contains&_inV=160076
返回以下500错误消息:
{"message":"An error occurred while generating the response object","error":"Edge cannot be found or created. Please check the format of the request."}
请求中的格式问题在哪里?
答案 0 :(得分:1)
您是否可以更改angularjs代码以将请求作为JSON发布(而不是将参数格式化为查询字符串)?将您的Content-Type
设置为application/json
(虽然角度可能已经为您做了。这些事情应该可以解决您的问题。