【问题标题】:How to Format Rexster POST to Add an Edge to a Titan Graph如何格式化 Rexster POST 以将边添加到 Titan 图形
【发布时间】:2014-07-25 16:13:14
【问题描述】:

我正在尝试使用 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."}

请求中的格式问题在哪里?

【问题讨论】:

  • 由于您是在本地运行它,请检查您的日志。
  • 是的,我做到了。我没有发现任何特别有用的东西,但我会再看看。

标签: angularjs rest titan rexster


【解决方案1】:

您能否更改您的 angularjs 代码以将请求作为 JSON 发布(而不是将参数格式化为查询字符串)?也将您的 Content-Type 设置为 application/json(尽管 Angular 可能已经为您这样做了。这些东西应该可以解决您的问题。

【讨论】:

    猜你喜欢
    • 2013-11-03
    • 2013-10-08
    • 2015-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-17
    • 2016-05-17
    • 2016-11-23
    相关资源
    最近更新 更多