Amazon Rekognition - CreateUserCommand InvalidParameterException: Request has invalid parameters

0

Hello all,

While using Amazon Rekognition APIs we are getting error as InvalidParameterException: Request has invalid parameters when using CreateUserCommand API.

Other few commands are working - eg: ListCollectionsCommand, ListUsersCommand

More details are as

  • Using node v18.16.0 (npm v9.5.1)
  • Using nestjs
  • Using "@aws-sdk/client-rekognition": "^3.409.0",

Sample code as

import { RekognitionClient } from "@aws-sdk/client-rekognition";
import { CreateCollectionCommand, ListCollectionsCommand, CreateUserCommand, ListUsersCommand,  } from  "@aws-sdk/client-rekognition";

// Init client
this.rekognition = new RekognitionClient({
    region: this.region,
    credentials: {
        secretAccessKey: this.secretAccessKey,
        accessKeyId: this.accessKeyId,
    },
});

// Call create user API
const createUserParams = {
    CollectionId: collectionId,
    UserId: userId,
    ClientRequestToken: 'dev' + new Date().getTime().toString()
};

/*
Where input sent is as
{
  CollectionId: 'test_dev',
  UserId: '1',
  ClientRequestToken: 'dev1694588820574'
}
*/

const createUserResponse =  await this.rekognition.send(new CreateUserCommand(createUserParams));

Getting error as

InvalidParameterException: Request has invalid parameters
    at de_InvalidParameterExceptionRes (src/node_modules/@aws-sdk/client-rekognition/dist-cjs/protocols/Aws_json1_1.js:4398:23)
    at de_CreateUserCommandError (src/node_modules/@aws-sdk/client-rekognition/dist-cjs/protocols/Aws_json1_1.js:1034:25)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at src/node_modules/@smithy/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24
    at src/node_modules/@aws-sdk/client-rekognition/node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:14:20
    at src/node_modules/@smithy/middleware-retry/dist-cjs/retryMiddleware.js:27:46
    at src/node_modules/@aws-sdk/client-rekognition/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26
    at AwsRekognitionService.createUsersInCollection (src/src/services/aws-rekognition/aws-rekognition.service.ts:115:45)
    at FaceIndexingService.indexRekognitionUsers (src/src/cron/faceIndexing.service.ts:214:4)
    at CJ.<anonymous> (src/node_modules/@nestjs/schedule/dist/schedule.explorer.js:88:17) {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: 'b4fef655-bfa7-4234-ad9b-bf4951088831',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  Code: 'InvalidParameterException',
  Logref: undefined,
  __type: 'InvalidParameterException'
}
  • Tried with AWS SDK 2 and 3 - for both - getting same error
  • Tried passing/not passing ClientRequestToken - for both - getting same error

Any help will be highly appreciated.

Thank you.

  • Could you share the account Id, region and timestamp for this call to troubleshoot what we received at the service end?

  • @Venkat is it safe to share account ID here?

manojL
posta 8 mesi fa261 visualizzazioni
2 Risposte
1

Hi,

can you try to add some letters before your '1' as UserId like 'user1'. This parameter is supposed to be a string. Your '1' is clearly a string but you may want to see what happens if you add some alphabetical chars.

Best.

Didier

profile pictureAWS
ESPERTO
con risposta 8 mesi fa
  • Heh, also thought about that and even checked the SDK source code but not an expert in JS, just expecting that something passed as string will be treated as string :)

  • Tried this. This seems to work, thank you.

0

Hi,

Several things to check:

  1. Is CollectionID: "test_dev" exist?
  2. Is UserId: "1" unique?

So far, I do not have other ideas about what could be wrong. Here is piece of documentation, maybe you find anything here: https://docs.aws.amazon.com/en_us/AWSJavaScriptSDK/v3/latest/clients/client-rekognition/interfaces/createusercommandinput.html#userid-1

profile picture
ESPERTO
con risposta 8 mesi fa
  • Thank you for your answer. I can confirm - 1 - collection exists 2 - the user being created is not present in the collection (and would be unique)

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande