Amplify-js: Can't seem to update custom attributes via Auth method

Created on 21 Nov 2018  ·  4Comments  ·  Source: aws-amplify/amplify-js

* Which Category is your question related to? *
Auth signUp
* What AWS Services are you utilizing? *
Cognito
* Provide additional details e.g. code snippets *
I am trying to register a new user and set a custom attribute. I created a custom attribute labelled 'favorite_flavor', but when it has saved in Cognito it has been renamed to custom:favorite_flavor. When I try and signUp the user using 'favorite_flavor' and I get a 'Attributes did not conform to the schema: favorite_flavor: Attribute does not exist in the schema.' response

Example code:

Auth.signUp({
      username: this.username.value,
      password: this.password.value,
      attributes: {
        email: this.email.value,
        favorite_flavor: "this is a test"
      }
    })
      .then(data => {
        console.log(data);
        this.setState({ toConfirm: true, userObj: data });
      })
      .catch(err => this.setState({ error: err.message }));
  };

If I need to try and write to custom:favorite_flavor then come someone help me in determining what i need to post up please?

Many thanks for any help!

Most helpful comment

@michaelsmedley try using “custom:favorite_flavor” as your attribute key.

All 4 comments

@michaelsmedley try using “custom:favorite_flavor” as your attribute key.

🤣🤣🤣

Well I feel like an idiot now, I did definitely try that I'm sure.

But yes, easily resolved now. Thanks for the prompt response

I have a similar issue and tried the same thing

signUp = async (username, password, email, birthdate, policycode) => {
    try {
      await Auth.signUp({ username, password, attributes: { email, birthdate, custom:policycode }})
      console.log('successful sign up..')
      this.setState({ stage: 1 })
    } catch (err) {
      console.log('error signing up...', err)
      alert(err.message)
    }
  }

But get now get an error message "Attributes did not conform to the schema: custom: Attribute does not exist in the schema.". As a noob I think I may be missing something obvious...

Any help would be most welcome thanks

Haven't tried it myself, but @gsandiford appears you're just setting custom: policycode. You want 'custom:policycode': policycode

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benevolentprof picture benevolentprof  ·  3Comments

rayhaanq picture rayhaanq  ·  3Comments

DougWoodCDS picture DougWoodCDS  ·  3Comments

rygo6 picture rygo6  ·  3Comments

cosmosof picture cosmosof  ·  3Comments