Get Project Membership method with node.js "your pagination token is invalid"

I basically pulled the node method from here:

https://developers.asana.com/reference/getprojectmembership

I used my own access token, but am receiving the following error:

message: ‘offset: Your pagination token is invalid.’,
help: ‘For more information on API status codes and how to handle them, read the docs on errors: Errors

The offset token provided looks like this:
‘offset’: “eyJ0eXAiOJiKV1iQLCJhbGciOiJIUzI1NiJ9”,

When I remove that key value pair it returns 1 page and that’s it (noted in the documentation). I want to return all pages because I know there are more than 1 member of the project.

Has anyone ran into this issue before?

Hi @Justin_Briones ,

Are you using the node client library? Could you post a code snippet? (obscure your private data)

Here’s the code i’m running without my access token:

const Asana = require('asana');

let client = Asana.ApiClient.instance;
let token = client.authentications['token'];


let projectMembershipsApiInstance = new Asana.ProjectMembershipsApi();
let project_gid = "1202149488381053"; // String | Globally unique identifier for the project.
let opts = { 
    'user': "me", 
    'limit': 100, 
    'offset': "eyJ0eXAiOJiKV1iQLCJhbGciOiJIUzI1NiJ9", 
    'opt_fields': "access_level,member,member.name,offset,parent,parent.name,path,uri"
};
projectMembershipsApiInstance.getProjectMembershipsForProject(project_gid, opts).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

I am. I installed the required package and it even ran when I removed the offset token.

The problem is when I do that it only returns 1 page.

@Justin_Briones I think the issue is two-fold:

  1. You can exclude the limit and offset properties from your opts object; the client libraries handle offsets for you and return all your results at once (you should use those if you’re calling the endpoint directly without using the library.
  2. Your user property (on the opts object) is filtering for only you, so you’re only seeing one result (yourself). If you comment that out, you should see the full membership.
1 Like

That worked!!

Now, it returns multiple members like this:

“gid”: “1202149488405370”,
“access_level”: “admin”,
“parent”: {
“gid”: “1202149488381053”,
“name”: "Keeper - Patrick / Truman / Gabe / Kyle "
}

Is there anyway to get the member.email? I tried including that in the opt field and it didn’t return anything different.

@Justin_Briones in the opt_fields property of your opts object, you’ll want to add (at minimum) user.email (I just tried this and it returned ok for me). What you’re seeing right now is the membership GID, the access level associated, and then the parent (project). You’re not receiving any user information rn because I think the documentation is wrong (you want to call for user, not member).

I just ran this myself with 'opt_fields': "access_level,user.email" and it worked.

1 Like

Awesome! That worked great!

Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.