javascriptentityapigeeusergrid

no user specified a usergrid error


When trying to add a user to a group with Apigee and Usergrid, using the example code from the apigee website, I keep receiving the error "no user specified"

How do I specify the user? The code is correct, and it seems like the apigee.js code has an issue referencing the username.

I tried passing the username may different ways, and I Googled until my fingers were numb.


Solution

  • When trying to add a user to a group with Apigee and Usergrid, using the example code from the apigee website, I kept receiving the error "no user specified"

    I tried passing the username may different ways, I googled until my fingers were numb, and I finally came up with the solution below. I'm posting here so others can hopefully use this solution should they experience the same issue when trying to add a user to a group.

    The original code in apigee.js is as follows (line 2692):

            options = {
            method: "POST",
            endpoint: "groups/" + this._path + "/users/" + options.user.get("username")
        };
    

    This is what I changed it to in order to get the username from the entity:

            options = {
            method: "POST",
            endpoint: "groups/" + this._path + "/users/" + options.user["entities"][0]["username"]
        };
    

    The endpoint needed to get the username, and the only way to do it was to pull it directly from the array.