1

I'm trying to annotate an assessment, for now from Postman but I'm getting 404 error from the URL that is posted on Google's guide. The URL I'm trying is

https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments/ASSESSMENT_ID

Of course substituting variables for my values. The body of the post request is

{
"annotation": "LEGITIMATE"
}

The response I get is 404. I even tried https://recaptchaenterprise.googleapis.com and this also returns 404. I wonder if the URL has changed.

Also if this is possible to do with the PHP SDK that would be better.

Whip
  • 1,891
  • 22
  • 43

2 Answers2

2

I dug around in recaptcha's sdk and found a method for annotation. This is not documented anywhere.

use Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentRequest\Annotation;
use Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentResponse;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;

require 'vendor/autoload.php';

$assessment = 'YOUR ASSESSMENT ID'; // /projects/PROJECT_ID/assessments/ASSESSMENT_ID
try {
    $client = new RecaptchaEnterpriseServiceClient([
        'credentials' => __DIR__.'/../vault/'.RECAPTCHA_SERVICE_CREDEN
    ]);

  $client->annotateAssessment($assessment, 1); // 1 = Legitimate, 2 = Fraudulent

} catch (Exception $e){
    $response['error'] = 'An error occurred: '.$e->getMessage();
}
Whip
  • 1,891
  • 22
  • 43
  • Were you able to add an array of reasons? I use JS but when I try to include reasons in the request like: reasons:["REASON_UNSPECIFIED"] it responds with the error: Error: 3 INVALID_ARGUMENT: Invalid reason. This is supposed to be an enum. But I'm not sure how to impement that. I've tried replacing the reasons with numbers and this still doesn't work. I know the reasons available can be found here: https://cloud.google.com/recaptcha-enterprise/docs/reference/rest/v1/projects.assessments/annotate#reason – Mr. J May 28 '23 at 23:57
  • No, I didn't send reasons. I'm not sure what you are doing wrong. Create a new question for that perhaps. – Whip May 29 '23 at 04:23
0

Typically, this occurs if the project ID is incorrect or if authentication failed for that project.

You can check this public documentation as guidance.

Siegfred V.
  • 1,143
  • 3
  • 12