Bad request (400) when trying to set phone_number to cognito account

0

Hello, I have a little problem with setting phone_number to newly created AWS cognito accounts. When I try to register a new user via

const command = new AdminCreateUserCommand({
       Username: userToCreate.email,
       UserAttributes: [
         {
           Name: CognitoProperties.PHONE_NUMBER,
           Value: `${userToCreate.phoneNumber}`,
         },
         {
           Name: CognitoProperties.EMAIL,
           Value: `${userToCreate.email}`,
         },
         {
           Name: CognitoProperties.FULL_NAME,
           Value: `${userToCreate.fullName}`,
         },
       ],

       UserPoolId: this.configService.get('AWS_COGNITO_USER_POOL_ID'),
     });
     const commandResult = await this.AWS_CLIENT.send(command);

I got the following error:

"name": "InvalidParameterException",
     "$fault": "client",
     "$metadata": {
       "httpStatusCode": 400,
       "requestId": "---REQUEST_ID----",
       "attempts": 1,
       "totalRetryDelay": 0
},
"__type": "InvalidParameterException"

I have tried multiple number formats, including the phone number provided in AWS Cognito documentation (+14325551212). Also, I have tried removing property phone_number from my request, which removed the error. The same error occurred when I tried to register a user with postman client. The interesting part is that even though cognito returns 400 error it still saves the user. Can you please suggest what am I doing wrong and help me fix that?

gefragt vor 7 Monaten81 Aufrufe
Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen