AWS.Comprehend возвращает 405 «Метод не разрешен» - PullRequest
0 голосов
/ 18 декабря 2018

Я пытаюсь использовать 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)

Со всеми наилучшими пожеланиями.Антон.

1 Ответ

0 голосов
/ 18 декабря 2018

Я запускаю aws config команду cli с теми же учетными данными, и проблема как-то решена.

...