PUT /Job/EnableJob/{id}/

Enables or disables a job.
 

Request

Method Request URI
put /API/Job/EnableJob/{id}/?sessionId=value

URI Parameters

URI Parameter Description
sessionId The current session ID. Specifying via an Authorization request header instead is recommended.

Path Parameters

Path Parameter Description
id The ID of the job to enable or disable.

Request Headers

Authorization: Bearer <Current session ID>

Request Body

Name: enabled
Type: System.Boolean

Response

Response Body

The operation completed successfully. The payload contains a System.Boolean indicating success (or failure if the job is running).

Response Codes

Response Code Description
200 The operation completed successfully.
400 The request contained one or more invalid parameters.
403 The caller does not have the necessary privileges for the attempted operation and/or the specified item.
404 An item with the specified ID was not found.
440 The caller is not associated with a valid session.

Examples

This example will login and disable the job with ID = be1614b2-5c83-4a88-86e8-a2a56b915c97.

C# Java JavaScript
using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Web.Script.Serialization;

   ...

using (HttpClient httpClient = new HttpClient())
{
	// Get Session Id
	string logonUri = "http://localhost:8004/Api/LogOn/";
	var logonOptions = new
	{
		accountName = "admin",
		password = "1234",
		cultureName = string.Empty,
		deleteOtherSessions = true,
		isWindowsLogOn = false
	};

	JavaScriptSerializer serializer = new JavaScriptSerializer();
	var requestBodyAsString = serializer.Serialize(logonOptions);
	StringContent content =
		new StringContent(
			requestBodyAsString,
			Encoding.UTF8,
			"application/json"
		);

	string jsonString = string.Empty;

	using (var response = httpClient.PostAsync(logonUri, content).Result)
	{
		jsonString =
			response.Content.ReadAsStringAsync().Result;
	}

	var obj = (Dictionary<string,object>) serializer.DeserializeObject(jsonString);
	string sessionId = obj["sessionId"].ToString();
	string url = "http://localhost:8004/API/Job/EnableJob/be1614b2-5c83-4a88-86e8-a2a56b915c97/";

	// Add an Authorization header
	httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", sessionId);

	// Define the request body
	HttpContent requestBody = null;
	requestBody = 
		new StringContent(@"
		false",Encoding.UTF8,"application/json");
	using (var response = httpClient.PutAsync(url, requestBody).Result)
	{
		if(response.StatusCode == HttpStatusCode.OK)
		{
			Console.WriteLine("Success");
		}
	}
}

		
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.apache.http.entity.StringEntity;
import org.json.JSONObject;

   ...

HttpClient httpClient = HttpClientBuilder.create().build();

String url = "http://localhost:8004";

// Get Session Id
String logonUri = url + "Api/LogOn/"
HttpPost httpPost = new HttpPost(logonUri);
StringEntity stringEntity = 
	new StringEntity("{
		+ "\"accountName\":\"admin\","
		+ "\"password":\"1234\","
		+ "\"cultureName\":\"\","
		+ "\"deleteOtherSessions\":false,"
		+ "\"isWindowsLogOn\":false"
		+ "}"
	);
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
HttpResponse httpResponse = httpClient.execute(httpPost);
String jsonString = EntityUtils.toString(httpResponse.getEntity());
JSONObject jsonObj = new JSONObject(jsonString);
String sessionId = jsonObj.getString("sessionId");

String requestUrl = "http://localhost:8004/API/Job/EnableJob/be1614b2-5c83-4a88-86e8-a2a56b915c97/";

// Define the Request Method.
HttpPut requstMethod = new HttpPut(requestUrl);

// Add an Authorization header
requstMethod.setHeader("Authorization", "Bearer " + sessionId);

// Define the Request Body.
StringEntity input =
	new StringEntity(
"false"	);
requstMethod.setEntity(input);
HttpResponse response = 
	httpClient.execute(requstMethod);

if(response.getStatusLine().getStatusCode() == 200)
{
	System.out.println("Success");
}

		
var baseUrl = 'http://localhost:8005';
var logonOptions =
{
	accountName: 'admin',
	password: '1234',
	cultureName: 'en-us',
	deleteOtherSessions: false,
	isWindowsLogOn: false
};
$.ajax({
	type: 'POST',
	url: baseUrl + '/Api/LogOn/',
	contentType: "application/json",
	data: JSON.stringify(logonOptions),
	success: function(logOnResultData) { 
		var sessionId = logOnResultData.sessionId; 

		var dataObject = "false";
		$.ajax({
			type: "PUT",
			url: baseUrl + "/API/Job/EnableJob/be1614b2-5c83-4a88-86e8-a2a56b915c97/",
			headers: { "Authorization": "Bearer " + sessionId },
			data: JSON.stringify(dataObject),
			contentType: "application/json",
			success: function(data) { 
				 // data = The operation completed
				 // successfully. The payload contains a
				 // System.Boolean indicating success (or
				 // failure if the job is running).

			},
			error: function(data) { alert('failed' + data); }
		});
	}
});