【问题标题】:Can't connect user to entity in Apigee Usergrid无法将用户连接到 Apigee Usergrid 中的实体
【发布时间】:2015-05-01 14:06:20
【问题描述】:

在使用 IOS API 时,我通过 ApigeeDataClient connectEntities 方法进行连接调用。我传入类型“users”,然后是用户的 uuid,然后是 connectionType“likes”,连接者类型为“songs”和歌曲的 uuid。

例子:

ApigeeClientResponse *response = [_dataClient connectEntities:@"users" connectorID:_apigeeUser.uuid connectionType:@"likes" connecteeType:@"songs" connecteeID:song.uuid];

当我建立连接时,它说成功,但是当我查看服务器上的数据时,似乎错误地保存了连接。例如,对于这首歌,我看到:

connecting :likes :/songs/b523a6aa-bb39-11e4-a2bb-35673af856e9/connecting/likes

歌曲的 uuid 似乎不在连接路径中。

与用户相关的连接也是如此。似乎连接到同一用户的是用户的 uuid。 uuid 是歌曲的 uuid,而不是用户的。当我调用 getEntityConnections 时,如下所示:

ApigeeClientResponse *response = [_dataClient getEntityConnections:@"songs" connectorID:_apigeeUser.uuid connectionType:@"likes" query:nil];

它返回一个错误,说“预期的歌曲,但得到了用户的 uuid。

实体 c831e1c4-2e6e-11e4-94ce-299efa8c6fd5 不是预期类型,预期歌曲,找到用户”

在查看 Apigee 本身时,在数据部分中,我看到了以下 sn-p:

"connections": {
  "likes": "/users/c831e1c4-2e6e-11e4-94ce-299efa8c6fd5/likes"
}

歌曲的 uuid 丢失。即使我尝试直接在服务器上更新 JSON,基本上将歌曲的 uuid 添加到末尾,它说它已保存,但它删除了歌曲的 uuid。

即使只是使用 curl 方法建立连接也不起作用。例如:

curl -X POST http://api.usergrid.com/peterdj/sandbox/users/bc2fc82a-bfa3-11e4-a994-b19963f177‌​9d/likes/c37f1eaa-bfa3-11e4-9141-97b3510c98e6

当我拨打电话时,我得到了这个

{"action":"post",
  "application":"0baaf590-2c1b-11e4-9bb5-11cb139f1620",
  "params":{
  },
  "path":"/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/likes",
  "uri":"https://api.usergrid.com/peterdj/sandbox/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/likes",
  "entities":[
  {
    "uuid":"c37f1eaa-bfa3-11e4-9141-97b3510c98e6",
    "type":"song",
    "name":"WingSpan",
    "created":1425167080842,
    "modified":1425167080842,
    "bpm":"124",
    "code":"WingSpan",
    "genre":"Progressive House",
    "metadata":{
      "connecting":{
        "likes":"/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/likes/c37f1eaa-bfa3-11e4-9141-97b3510c98e6/connecting/likes"
      },
      "path":"/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/likes/c37f1eaa-bfa3-11e4-9141-97b3510c98e6"
    },
    "title":"Wing Span"
  }
],
  "timestamp":1425246006718,
  "duration":78,
  "organization":"peterdj",
  "applicationName":"sandbox"
}

请注意,生成的连接路径在返回时似乎是正确的,但在执行另一个 GET curl 时,如下所示:

curl http://api.usergrid.com/peterdj/sandbox/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d

歌曲的 uuid 不存在:

{
"action" : "get",
"application" : "0baaf590-2c1b-11e4-9bb5-11cb139f1620",
"params" : { },
"path" : "/users",
"uri" : "https://api.usergrid.com/peterdj/sandbox/users",
"entities" : [ {
   "uuid" : "bc2fc82a-bfa3-11e4-a994-b19963f1779d",
   "type" : "user",
   "name" : "peter",
   "created" : 1425167068578,
   "modified" : 1425167495412,
   "username" : "peterdj",
   "email" : "asdf@adf.com",
   "activated" : true,
   "picture" :"",
     "metadata" : {
     "path" : "/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d",
     "sets" : {
       "rolenames" : "/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/roles",
       "permissions" : "/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/permissions"
     },
     "connections" : {
       "likes" : "/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/likes"
     },
     "collections" : {
       "activities" : "/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/activities",
       "devices" : "/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/devices",
      "feed" : "/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/feed",
      "groups" : "/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/groups",
      "roles" : "/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/roles",
      "following" : "/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/following",
     "followers" : "/users/bc2fc82a-bfa3-11e4-a994-b19963f1779d/followers"
    }
  }
} ],
"timestamp" : 1425311662762,
"duration" : 12,
"organization" : "peterdj",
"applicationName" : "sandbox"
}

这是实体与 Apigee/Usergrid 连接的错误,还是我做错了什么?

谢谢

【问题讨论】:

  • 如果在 curl POST 之后调用 curl http://api.usergrid.com/peterdj/sandbox/users/bc2fc82a-bfa3-11e4-a994-b19963f177‌​9d/likes 会发生什么?
  • 我在原始帖子中发布了 curl 调用中返回的内容(因此可以正确格式化)。
  • 好的,那么连接肯定可以正常工作 - 您可以看到它出现在“正在连接”的元数据中。如果您在同一端点上执行 GET,您将得到相同的响应。
  • 不,请参见上面的示例。生成的歌曲的 uuid 被截断
  • 您必须在其末尾附加/likes - 看看docs on retrieving connections。 Imo 他们也很困惑你的头:-/

标签: ios apigee usergrid mbaas


【解决方案1】:

好吧,事实证明,感谢@remus 的 cmets,我已经弄明白了。

在本次通话中: ApigeeClientResponse *response = [_dataClient getEntityConnections:@"songs" connectorID:_apigeeUser.uuid connectionType:@"likes" query:nil];

连接需要是“用户”,而不是“歌曲”。现在工作。谢谢@remus

【讨论】:

  • 请您接受这个答案,这样问题就不再是“未回答”了吗?谢谢!
  • 很抱歉,检查为已回答!
猜你喜欢
  • 2013-11-28
  • 2015-02-21
  • 1970-01-01
  • 2015-02-14
  • 2023-03-10
  • 2015-01-21
  • 1970-01-01
  • 2014-02-07
  • 1970-01-01
相关资源
最近更新 更多