Blog - API

API documentation

API documentation

Account

/campaign_hg/stop/<campaign_id> PUT

Stops a campaign. Only RUNNING campaign can be stopped.

Parameters:

<campaign_id>

Campaign ID

Example values: e7162dd17b83

Return values:

SUCCESS

status=SUCCESS, campaign_id=[campaign id]

ERROR

status=ERROR, error=[error message*]

*[NO SUCH CAMPAIGN|CAMPAIGN IS PAUSED_ADMIN|CAMPAIGN IS ALREADY FINISHED]

Code:

cURL:

curl -H "MicroworkersApiKey:YOUR_API_KEY" -X PUT https://api.microworkers.com/campaign_hg/stop/<campaign_id> -d ""

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/stop/137956568899");
$client->setMethod("PUT");
$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/stop/137956568899');
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/stop/137956568899')
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();
    string body = MW_API_Client.putRequest("/campaign_hg/stop/137956568899", postData);
    Console.WriteLine (body);
  }
}

Examples:

Output (Success):

https://api.microworkers.com/campaign_hg/stop/137956568899

{
  "status": "SUCCESS",
  "campaign_id": "137956568899"
}

Output (Error):

https://api.microworkers.com/campaign_hg/stop/98df32d4c101

{
  "status": "ERROR",
  "campaign_id": "98df32d4c101",
  "error": "CAMPAIGN IS ALREADY FINISHED"
}