Receiving 400 bad request in annotate login events

exact error : POST https://recaptchaenterprise.googleapis.com/v1/projects/770978332111/assessments/1a4b51fac6000000:ann... net::ERR_ABORTED 400 (Bad Request)

code:

async function annotateAssessment(assessmentID, annotation, reasons, accountId) {
const annotateUrl = `https://recaptchaenterprise.googleapis.com/v1/${assessmentID}:annotate`;
const annotateData = {
annotation: "", // "LEGITIMATE" or "FRAUDULENT"
reasons: reasons, // Optional array of reasons (e.g., ["AUTOMATION"])
accountId: "" // Optional, the identifier for the user's account on your website
};
try {
const response = await fetch(annotateUrl, {
method: 'POST',
mode: 'no-cors',
body: JSON.stringify(annotateData),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer my token' , // Include your reCAPTCHA API token here

}
});

if (!response.ok) {
// Handle HTTP errors
const errorData = await response.json();
console.error("Error annotating the assessment:", errorData);
return;
}
const result = await response.json();
console.log("Annotation result:", result);
} catch (error) {
console.error("Error annotating the assessment:", error);
}
}


my token is generated and tried  from  below ways 
1. OAuth 2.0 Playground
2. creating a new service account in google cloud (using that key) as well as downloading the json and replacing it with path 

can someone reply the solution for above error and please tell if the way we are working for token generation is correct or wrong

0 1 206
1 REPLY 1

Hi!

I wonder if it is because you have an empty string in the ENUM for "annotation". Did you mean to have that, or you missed taking it from the params?