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회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠