R
R
romasovest2017-10-29 21:32:40
JavaScript
romasovest, 2017-10-29 21:32:40

How to do anti-captcha on AJAX requests?

Judging by the documentation https://anticaptcha.atlassian.net/wiki/spaces/API/... the request template looks like this:

{
    "clientKey":"dce6bcbb1a728ea8d563de6d169a2057",
    "task":
        {
            "type":"ImageToTextTask",
            "body":"BASE64_BODY_HERE!",
            "phrase":false,
            "case":false,
            "numeric":false,
            "math":0,
            "minLength":0,
            "maxLength":0
        }
}


My request looks like this:
(On the account, half a buck in total, don’t be rude, please. I give my key so that you can easily try the solution)

$.ajax({
  url: "https://api.anti-captcha.com/createTask",
  type: "POST",
  data: {
    "clientKey":"1922a44efdd8fe67241ebbacc51a9655",
    "task": {
        "type":"ImageToTextTask",
        "body":"тут картинка с капчей в BASE64, для Тостера многовато букв",
        "phrase":false,
        "case":false,
        "numeric":false,
        "math":0,
        "minLength":0,
        "maxLength":0
    }
  },
  success: function(r){
    console.log(r);
  },
  dataType: "json"
});


For some reason I get this error:

errorCode:"ERROR_TASK_ABSENT"
errorDescription:"Task property is empty or not set. Please refer to API v2 documentation."
errorId:22

Error documentation: https://anticaptcha.atlassian.net/wiki/spaces/API/...

Captcha example: https://api.vk.com/captcha.php?sid=940329122405&s=1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Gerasimov, 2017-10-29
@romasovest

Request format: JSON POST
JSON.stringify data before sending

N
Nikita Kit, 2017-10-29
@ShadowOfCasper

try adding cache: false and replace success with complete

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question