AWS Cognito ListUsers InvalidParameterException using AttributesToGet on custom attributes

Viewed 3884

Using the following AWS Lambda-based app client, I'm trying to list all users from my Cognito user pool.

let AWS = require('aws-sdk')
const COGNITO_CLIENT = new AWS.CognitoIdentityServiceProvider()
COGNITO_CLIENT.listUsers({
  UserPoolId: 'MyUserPoolId',
  AttributesToGet: ['default_attribute', 'custom:my_attribute']
}, callback)

Everything works fine when querying for all attributes by default (AttributesToGet: [] // or excluding this field altogether). However, when targeting custom attributes, the InvalidParameterException is raised. This is using the Amazon SDK for Node.js.

Targeting default attributes are allowed though:

AttributesToGet: ['email', 'name', /* other non-custom */]
2 Answers

Please remove the "AttributesToGet" and try.

Your code is correct. However, I am on the Cognito team and we don't support search on custom attributes at this point.

Related