Blog - API

API documentation

API documentation

Account

/campaign_hg/rate_tasks/<campaign_id> PUT

Rates non-rated tasks.

Parameters:

<campaign_id>

Campaign ID

Example values: e7162dd17b83

PUT data

 

 

id_task[]

Task IDs

rating[]

[OK|NOK|REVISE]

comment[]

Explanation to Worker why task wasn't accepted.

This field is mandatory when rating NOK or REVISE.

bonus[]

Optional bonus you wish to give to worker.

Bonus amount must be in range ("payment per task" x 0.1 .. "payment per task" x 2).

favorite[]

[add|remove]

Optional

Return values:

SUCCESS

status=SUCCESS, campaign_id=[campaign id], tasks=[tasks]

ERROR

status=ERROR, campaign_id, error=[error message*]

*[NO SUCH CAMPAIGN|INPUT DATA|SYSTEM ERROR]

Code:

cURL:

curl -H "MicroworkersApiKey:YOUR_API_KEY" -X PUT https://api.microworkers.com/campaign_hg/rate_tasks/<campaign_id> -d "id_task[]=<id_task>&rating[]=<rating>&comment[]=<comment>"

PHP:

<?php

include "includes/RESTClient.php";
define("cAPI_KEY", "YOUR_API_KEY");
define("cAPI_URL", "https://api.microworkers.com");
$client = new RESTClient();
$client->setApiKey(cAPI_KEY);
$client->setUrl(cAPI_URL . "/campaign_hg/rate_tasks/e7162dd17b83");
$client->setMethod("PUT");

$client->setData(
array('id_task[]' => '123456', 'rating[]' => 'OK', 'comment[]' => '')
);

$client->execute();
$response = $client->getLastResponse();
$client->resetClient();
echo $response;

?>

Perl:

use MW_API;
use Data::Dumper qw(Dumper);
my $mw_api = MW_API->new('api_key' => 'YOUR_API_KEY');
my $res = $mw_api->do_request('PUT', '/campaign_hg/rate_tasks/e7162dd17b83', {
  'id_task[]' => '123456',
  'rating[]' => 'OK',
  'comment[]' => ''
});
print Dumper($res);

Python:

from pprint import pprint
from MW_API import MW_API
mw_api = MW_API('YOUR_API_KEY')
res = mw_api.do_request('PUT', '/campaign_hg/rate_tasks/e7162dd17b83', {
  'id_task[]': '123456',
  'rating[]': 'OK',
  'comment[]': ''
})
pprint(res)

C#:

using System;
using MWAPI;
using System.Collections.Specialized;

public class Test
{
  public static void Main (string[] args)
  {
    MW_API MW_API_Client = new MW_API ("YOUR_API_KEY");
    NameValueCollection postData = new NameValueCollection();
    postData.Add("id_task[]", "123456");
    postData.Add("rating[]", "OK");
    postData.Add("comment[]", "");
    string body = MW_API_Client.putRequest("/campaign_hg/rate_tasks/e7162dd17b83", postData);
    Console.WriteLine (body);
  }
}

Examples:

Output (Success):

{
  "status": "SUCCESS",
  "campaign_id":"e7162dd17b83",
  "tasks":[
    {
      "id_task":"1234567",
      "rating":"OK",
      "comment":"",
      "success":true
    },{
      "id_task":"1234568",
      "rating":"NOK",
      "comment":"test",
      "success":true
    },{
      "id_task":"1234569",
      "rating":"NOK",
      "comment":"",
      "errors":["comment IS MANDATORY"]
    },{
      "id_task":"1234570",
      "rating":"OK",
      "bonus":10000,
      "comment":"",
      "errors":["Bonus you entered is outside allowed values"]
    },{
      "id_task":"1234568",
      "rating":"NOK",
      "comment":"",
      "errors":["id_task IS NOT UNIQUE"]
    },{
      "id_task":"1234571",
      "rating":"OK",
      "bonus":1.00,
      "comment":"",
      "errors":["Your account balance is too low to add bonus"]
  }] }

Output (Error):

{
  "status": "ERROR",
  "campaign_id": "a699bb9b2e7b",
  "error": "NO SUCH CAMPAIGN"
}