0

I am attempting to post an annotation request to the Google Recaptchaenterprise API as follows:

async function() {

  const body = {
    annotation: "FRAUDULENT",
    reasons:["REASON_UNSPECIFIED"]
  };

  try {

    const response = await fetch(`https://recaptchaenterprise.googleapis.com/v1/projects/${PROJECT_ID}/assessments/${ASSESSMENT_ID}:annotate`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Authorization": `Bearer ${token}`
      },
      body: JSON.stringify(body)
    });

    const result = await response;

    return result;

  } catch (error) {

    return error;

  }

}

I receive a response as follows (in Node.js):

{
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: null
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://recaptchaenterprise.googleapis.com/v1/projects/recaptchaenterpriseprojectname/assessments/projects/111111111111/assessments/1111111111111111:annotate',
    status: 404,
    statusText: 'Not Found',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}

I'm not sure if the assessment has been annotated based on this response. I've even tried enabling logs to figure this out without success but that's a separate issue. The status says 404 and the statusText says 'Not Found'. So my assumption is that the annotation has not been completed. Note I have read the post here:

Can not annotate assessment from recaptcha enterprise

But I am attempting to do this using the JavaScript and the Google reCaptcha API not the client library found here:

https://www.npmjs.com/package/@google-cloud/recaptcha-enterprise

Also see:

https://cloud.google.com/recaptcha-enterprise/docs/annotate-assessment

Thanks for your help.

Mr. J
  • 307
  • 2
  • 9

0 Answers0