简体   繁体   中英

Aws dynamodb Error Error [UnknownError]: Not Found (aws-sdk)

I'm trying to add elements in a table in dynamodb like in the example below but when I run it I get this error message:

Error Error [UnknownError]: Not Found
    at Request.extractError (C:\Users\caval\Documents\GitRepos\express-es6-rest-api\node_modules\aws-sdk\lib\protocol\json.js:51:27)
    at Request.callListeners (C:\Users\caval\Documents\GitRepos\express-es6-rest-api\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
    at Request.emit (C:\Users\caval\Documents\GitRepos\express-es6-rest-api\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (C:\Users\caval\Documents\GitRepos\express-es6-rest-api\node_modules\aws-sdk\lib\request.js:688:14)
    at Request.transition (C:\Users\caval\Documents\GitRepos\express-es6-rest-api\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (C:\Users\caval\Documents\GitRepos\express-es6-rest-api\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at C:\Users\caval\Documents\GitRepos\express-es6-rest-api\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request.<anonymous> (C:\Users\caval\Documents\GitRepos\express-es6-rest-api\node_modules\aws-sdk\lib\request.js:38:9)
    at Request.<anonymous> (C:\Users\caval\Documents\GitRepos\express-es6-rest-api\node_modules\aws-sdk\lib\request.js:690:12)
    at Request.callListeners (C:\Users\caval\Documents\GitRepos\express-es6-rest-api\node_modules\aws-sdk\lib\sequential_executor.js:116:18) {
  message: 'Not Found',
  code: 'UnknownError',
  statusCode: 404,
  time: 2020-07-05T08:21:43.936Z,
  requestId: undefined,
  retryable: false,
  retryDelay: 38.04958058577693
}

I tried also with getItems , delteItems ... and I get the same error . Removing it I don't get any error, so the error come from these methods for sure.

   let ddb = new AWS.DynamoDB({
      apiVersion: "2012-08-10",
      endpoint: "http://localhost:8080",
      region: "eu-west-1",
      accessKeyId: AWS.config.credentials.accessKeyId,
      secretAccessKey: AWS.config.credentials.secretAccessKey,
    });

    let params = {
      TableName: "namOfTheTable",
      Item: {
        uuid: { N: "123" },
        name: { S: JSON.stringify(req.query.mod) },
      },
    };

    const addMod = ddb.putItem(params, function (err, data) {
      if (err) {
        console.log("Error", err);
      } else {
        console.log("Success", data);
      }
    });

Edit: the problem was that I was not using the local version so I needed to remove the property endpoint

This 404 not found error is being returned from http://localhost:8080 .

Are you sure that DynamoDB local is running, and if so have you set it to run on port 8080 ?

By default DynamoDB local runs on port 8000 according to the documentation on local DynamoDB usage .

Additional Note

After discussing with OP, DynamoDB local was not setup on their host machine which is what caused the 404 issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM