我正在尝试使用 AWS.Comprehend 但保持获取 405'不允许使用方法' 我不确定此授权问题还是其他问题。 能否请您帮我找出问题所在?
const comprehend = sentence => (new Promise((resolve, reject) => {
const comprehend = new AWS.Comprehend({
accessKeyId: process.env.AWSAccessKeyId,
secretAccessKey: process.env.AWSSecretKey,
region: 'eu-central-1', // EU (Frankfurt)
endpoint: 'https://rds.eu-central-1.amazonaws.com',
apiVersion: '2017-11-27',
});
comprehend.batchDetectEntities({
LanguageCode: 'en',
TextList: sentence.match(/[\w\W\s\n.]{0,4999}/g),
}, (error, data) => {
console.log(error, data);
if (error) return reject(error);
return resolve(data);
});
}));
结果是
{ UnknownError: Method Not Allowed
at Request.extractError (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/protocol/json.js:51:27)
at Request.callListeners (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/silentimp/Work/builder/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
message: 'Method Not Allowed',
code: 'UnknownError',
statusCode: 405,
time: 2018-12-18T16:14:20.652Z,
requestId: undefined,
retryable: false,
retryDelay: 44.438842190393046 } null
(node:6446) UnhandledPromiseRejectionWarning: UnknownError: Method Not Allowed
at Request.extractError (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/protocol/json.js:51:27)
at Request.callListeners (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/silentimp/Work/builder/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/Users/silentimp/Work/builder/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
致以最诚挚的问候。安东。
答案 0 :(得分:-1)
我以相同的凭据运行 aws config cli命令,并以某种方式解决了问题。