title: InvalidParameterType: Expected params.UserAttributes Name to be a string AWS Cognito SDK
body: <p>I am totally new to aws cognito sdk. I am trying to sign up a user using cognito sdk in Node.js. Whenever I try to run the node.js code, It throws me an error saying </p>
  
  <pre><code>    { MultipleValidationErrors: There were 5 validation errors:
  * InvalidParameterType: Expected params.UserAttributes[0].Name to be a string
  * InvalidParameterType: Expected params.UserAttributes[1].Name to be a string
  * InvalidParameterType: Expected params.UserAttributes[2].Name to be a string
  * InvalidParameterType: Expected params.UserAttributes[3].Name to be a string
  * InvalidParameterType: Expected params.UserAttributes[4].Name to be a string
  </code></pre>
  
  <p>Here is my code.</p>
  
  <p>index.js</p>
  
  <pre><code>var AWSCognito = require('aws-sdk');
  var AmazonCognitoIdentity = require('amazon-cognito-identity-js');
  var CognitoSDK = require('amazon-cognito-identity-js-node');
  
  AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool = CognitoSDK.CognitoUserPool;
  AWSCognito.CognitoIdentityServiceProvider.CognitoUser = CognitoSDK.CognitoUser;
  AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute = CognitoSDK.CognitoUserAttribute;  
  AWSCognito.config.region = 'us-west-2';   
  var poolData = {
      UserPoolId : '...', // your user pool id here
      ClientId : '....' // your app client id here
  };
  var userPool =
       new AmazonCognitoIdentity.CognitoUserPool(poolData);
  var userData = {
      Username : 'jayanthv', // your username here
      Pool : userPool
  };    
  //---------------Signing up Users for Your App---------------------   
  var attributeList = [];    
  var dataEmail = {
      Name : JSON.stringify("email"),
      Value : 'jayanth49@gmail.com' // your email here
  };
  var dataPhoneNumber = {
      Name : 'phone_number',
      Value : '8326623393' // your phone number here with +country code and no delimiters in front
  };
  var dataName = {
      Name : 'name',
      Value : 'Jayanth' // your phone number here with +country code and no delimiters in front
  };
  var dataProfile = {
      Name : 'profile',
      Value : 'SamplePortal' // your phone number here with +country code and no delimiters in front
  };
  var dataGender = {
      Name : 'gender',
      Value : 'Male' // your phone number here with +country code and no delimiters in front
  };
  var attributeEmail =
      new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataEmail);
  var attributePhoneNumber =
      new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataPhoneNumber);
  var attributeName =
      new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataName);
  var attributeProfile =
      new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataProfile);
  var attributeGender =
      new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataGender);
  attributeList.push(attributeEmail);
  attributeList.push(attributePhoneNumber);
  attributeList.push(attributeName);
  attributeList.push(attributeProfile);
  attributeList.push(attributeGender);
  
  var cognitoUser;
  userPool.signUp('jayanthv', 'J@asdada', attributeList, null, function(err, result){
      if (err) {
          console.log(err);
          return;
      }
      cognitoUser = result.user;
      console.log('user name is ' + cognitoUser.getUsername());
  });
  </code></pre>
  
  <p>I don't really have any idea why this occurs. I have searched a lot in aws forums  and stack overflow. I would be happy if anyone can help me solve this issue.</p>
  
  <p>---UPDATED CODE---</p>
  
  <p>Followed the below documentation which explains in detail how to use the API calls.</p>
  
  <p><a href="http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html" rel="nofollow noreferrer">http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html</a></p>
  
  <p>Here is my updated code.
  index.js</p>
  
  <pre><code>var AWSCognito = require('aws-sdk');
  
  AWSCognito.config.region = 'us-west-2';
  
  exports.handler = (event, context, callback) =&gt; {
  
      var params = {
          ClientId: event.ClientId, /* required */
          Password: event.Password, /* required */
          Username: event.Username, /* required */
  
          UserAttributes: [
              {
                  Name: 'email', /* required */
                  Value: event.email
              },
              {
                  Name: 'gender',
                  Value: event.gender
              },
              {
                  Name: 'name',
                  Value: event.name
              },
              {
                  Name: 'phone_number',
                  Value: event.phone_number
              },
              {
                  Name: 'profile',
                  Value: event.profile
              }
              /* more attributes if needed */
          ]
      };
  
      var userPool = new AWSCognito.CognitoIdentityServiceProvider();
      var responseData = null;
      userPool.signUp(params, function(err, data) {
          if (err) console.log(err, err.stack); // an error occurred
          else    {
              console.log(data);
              responseData = data;
          }
                         // successful response
      });
  
  
      console.log(responseData);
      callback(responseData, null );
  };
  </code></pre>
  
  <p>The above code is written and tested in a Lambda Function.</p>