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?

已提問 7 個月前檢視次數 81 次
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南