One or more parameter values were invalid: Type mismatch for key xyz expected: S actual: M

First note the version of the AWS SDK V1 vs V2!

Also note the syntax for the client vs resource API of boto3. {'UserName':{'S':UserName} is the syntax used for the boto3 client and this solution is for the boto3 resource variant.

boto3 client put_item reference – https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Client.put_item

boto3 resource put_item reference - https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Table.put_item

client syntax

{'UserName':{'S':UserName},

resource syntax

{'UserName':UserName,

For my specific case, this fixed it up:

table.put_item(Item={'UserName':UserName,'Email':Email,'Score':Score,'Level':Level,'Mobile':Mobile,'Magic':Magic})