Calling AWS-Comprehend API throws error -> "InvalidRequestException: Invalid resource ARN: null"

12 views Asked by At

Here is my piece of code in React for calling AWS-Comprehend API

Trying to develop a Proof-Of-Concept application to use AWS's NLP algorithm.

import { ComprehendClient, ListDatasetsCommand } from "@aws-sdk/client-comprehend";
function App() {
    const analyzeSentiment = async (dataToBeAnalyzed) => {
    const client = new ComprehendClient({
      region: process.env.REACT_APP_AWS_REGION,
      version: "latest",
      credentials: {
        accessKeyId: process.env.REACT_APP_AWS_ACCESS_KEY,
        secretAccessKey: process.env.REACT_APP_AWS_SECRET_KEY,
      },
    });

    const params = { LanguageCode: 'en',Text: dataToBeAnalyzed };
    const command = new ListDatasetsCommand(params);
    try {
        const data = await client.send(command);
        // process data
        if (data) {
          console.log("setExtractedData: ", JSON.stringify(data))
        }
      } catch (error) {
           const { requestId, cfId, extendedRequestId } = error.$metadata;
           console.log({ requestId, cfId, extendedRequestId });
      }
     return (<></>)
}

When I call function "analyzeSentiment" with the text (returned from my AWS-Textract API I get a error:

Some Error ocurrent in process sentiments: InvalidRequestException: Invalid resource ARN: null

Can anyone help me figure what am I doing wrong and a remedy to this. Would appreciate your help.

I was expecting the output from "ListDatasetsCommand" API call but I am getting an error.

InvalidRequestException: Invalid resource ARN: null

0

There are 0 answers