Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Error #1

Closed
tonywong625 opened this issue Aug 11, 2015 · 3 comments
Closed

AWS Error #1

tonywong625 opened this issue Aug 11, 2015 · 3 comments

Comments

@tonywong625
Copy link

Hey there,

I am trying to save (putItem) and item however I am not sure how to specify the type of value using the package.

This is my code:

    $model = new \App\Models\dynamoModel();
    $model->id = '2123123123123';
    $model->name = 'Tony';
    $model->save(); 

I am getting the following error:

DynamoDbException in WrappedHttpHandler.php line 152:
Error executing "PutItem" on "https://dynamodb.us-east-1.amazonaws.com"; AWS HTTP error: Client error: 400 ValidationException (client): One or more parameter values were invalid: Type mismatch for key id expected: N actual: S - {"__type":"com.amazon.coral.validate#ValidationException","message":"One or more parameter values were invalid: Type mismatch for key id expected: N actual: S"}

Thanks!

@tonywong625
Copy link
Author

Just got it working:

Changed my code to the following

    $model = new \App\Models\dynamoModel();

    $model->id = 212;
    $model->name = 'Tony;
    $model->save();

Changed some code in my model as well

class dynamoModel extends DynamoDbModel
{
    protected $table = 'test';

    protected $fillable = ['name'];

    protected $dynamoDbIndexKeys = [
        'S' => 'id',
    ];
}

@baopham
Copy link
Owner

baopham commented Aug 11, 2015

@tonywong625 you shouldnt' have to specify protected $dynamoDbIndexKeys for the primary key, that property is for global / local indexes. Can you try to use uuid to generate the primary key instead? possibly the marshaler parsed your id to a number.

@baopham
Copy link
Owner

baopham commented Aug 11, 2015

Right, just looked at your code more closely. You had your primary key as a number, try uuid (https://github.com/ramsey/uuid)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants