0

When using the IOS API, I'm making a call to connect via the ApigeeDataClient connectEntities method. I pass in the type "users", then the user's uuid, then connectionType "likes", with the connectee type of "songs" and the song's uuid.

Example:

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

When I make the connection, it says successful, but when I look at the data on the server, it seems to save the connection incorrectly. For example, for the song, I see:

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

It looks like the song's uuid isn't in the connecting path.

The same is true for the connection related to the user. It's the user's uuid that seems to be connected to the same user. The uuid is that of the song's uuid, not the user's. When I make the call to getEntityConnections, like so:

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

It returns an error, saying "expected song, but got user's uuid.

Entity c831e1c4-2e6e-11e4-94ce-299efa8c6fd5 is not the expected type, expected song, found user"

In looking in Apigee itself, in the data section, I see the following snippet:

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

The song's uuid is missing. Even when I try to update the JSON directly on the server, basically adding the song's uuid to the end, it says it's saved, but it removes the song's uuid.

Even just using the curl method to make a connection doesn't work. For example:

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

When I make that call, I get this

{"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"
}

Notice that the resulting connecting path seems correct when it's returned, but when do another GET curl, as so:

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

The song's uuid isn't there:

{
"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"
}

Is this a bug with the entity connections with Apigee/Usergrid or am I doing something wrong?

Thanks

Peter Hale
  • 119
  • 4
  • What happens if you call `curl http://api.usergrid.com/peterdj/sandbox/users/bc2fc82a-bfa3-11e4-a994-b19963f177‌​9d/likes` after making that curl POST? – brandonscript Mar 01 '15 at 16:06
  • I posted what gets returned in the curl call in the original post (so it can be correctly formatted). – Peter Hale Mar 01 '15 at 21:54
  • Ok, the connection is definitely working then - you can see it appear in the "connecting" metadata. If you do a GET on the same endpoint you'll get the same response. – brandonscript Mar 01 '15 at 22:20
  • Nope, see the example above. The resulting song's uuid is chopped off – Peter Hale Mar 02 '15 at 16:00
  • You've got to append `/likes` at the end of it - have a look at the [docs on retrieving connections](http://apigee.com/docs/app-services/content/retrieving-user-connection-data). Imo they're pretty confusing to wrap your head around too :-/ – brandonscript Mar 02 '15 at 16:02
  • Oh wait..you're right. Now I'll check on how it works in IOS, I wonder if it's some bug in the IOS SDK. – Peter Hale Mar 02 '15 at 17:28
  • If it's definitely not working as expected in the SDK, you should be able to raise an issue on the [github page](https://github.com/apigee/apigee-ios-sdk). – brandonscript Mar 02 '15 at 17:33

1 Answers1

1

Well, turns out, thanks to the comments by @remus, I've figured it out.

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

The connection needs to be "users", not "songs". Works now. Thanks @remus

Peter Hale
  • 119
  • 4