I am attempting to use AWS Rekognition API through the AWS Javascript SDK and am receiving UnknownError: Bad Request when I attempt to start any of their detections services. I want to run label detection, but have the same error while attempting the others, such as celebrity face detection. I have made sure that my account has access to the Rekognition API and made sure that my credentials are correct (or at least the same credentials work for S3 attached to the same account).
My Code
var aws = require('aws-sdk');
const region = 's3-us-west-2';
const bucket = process.env.S3_VIDEO_BUCKET;
var requesttoken = randString(10) //generates random string
var key = 'path/to/key.mp4';
// used to check for keys to available files
var service = new aws.S3({
accessKeyId: process.env.ACCESS_KEY,
secretAccessKey: process.env.ACCESS_SECRET,
region: region,
endpoint: 'https://'+region+'.amazonaws.com/',
})
var rekognition = new aws.Rekognition({
accessKeyId: process.env.ACCESS_KEY,
secretAccessKey: process.env.ACCESS_SECRET,
region: region,
endpoint: 'https://'+region+'.amazonaws.com/',
apiVersion: '2016-06-27'
})
// check that key is reachable in S3
this.service.getObject({Bucket:bucket,Key:key}, function(err, data){
if(err){
console.error(err, err.stack)
} else {
console.log(data)
}
})
var params = {
Video: {
S3Object: {
Bucket: bucket,
Name: key
}
},
ClientRequestToken: requesttoken,
NotificationChannel: {
RoleArn: 'arn:aws:sns:us-west-2:000000000:example',
SNSTopicArn: 'example'
}
};
rekognition.startContentModeration(params, (err,data)=>{
if (err) {console.log(err, err.stack); return;};
console.log(data)
})
When I run this code I get
{ UnknownError: Bad Request
at Request.extractError
(/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/protocol/json.js:48:27)
at Request.callListeners (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
message: 'Bad Request',
code: 'UnknownError',
statusCode: 400,
time: 2018-06-29T21:08:27.184Z,
requestId: '2809C3770B525EF0',
retryable: false,
retryDelay: 57.00430269412582 }
My Question(s)
Is anyone familiar enough with the Rekognition API/AWS in conjunction with the JS SDK that they know what Bad Request might be indicating in this circumstance? Is there somewhere in the AWS Documentation that explains what this error might indicate?