Run task for specific model
Run different tasks based on the model status (deployed or not) and request body. One task activates or deactivates a deployed model. The other task deploys a model based on a model ID.
Syntax.
POST /model/{modelId}| Property | Data type | Description |
|---|---|---|
| apiKey header | String | Required. To authenticate API call. |
| modelId path | Integer | Required. ID of model to retrieve. |
| content-type header | String | Required. To indicate the media type of the resource. The value must be application/json. |
| classifierId body | Integer | Required. The classifier ID is provided to deploy a specific model. Use GET
/model/{modelId} function to get the classifiers information. An example is {
"classifierId" : 11 } |
| active body | Boolean | Required. The active parameter can be true or false. True activates the deployed model. False deactivates the deployed model. |
- Curl
-
curl -X POST -u 'Functional ID:Password' 'https://requesturl/ca/rest/content/v1/model/{modelId}' -H 'apiKey: ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=' -H 'Content-Type: application/json' -d '{ "classifierId": 11 }' - Java
-
import java.io.IOException; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.RequestBody; import java.util.Base64; import okhttp3.MediaType; public class testcode { public static void main(String[] args) { String encoding = Base64.getEncoder().encodeToString(("Functional ID:Password").getBytes()); OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/json;"); RequestBody body = RequestBody.create(mediaType, '{"classifierId": 11}'); Request request = new Request.Builder() .url("https://requesturl/ca/rest/content/v1/model/{modelId}") .post(body) .addHeader("apiKey", "ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=") .addHeader("Authorization", "Basic " + encoding) .build(); try { Response response = client.newCall(request).execute(); System.out.println(response.body().string()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } /* * The JAR files in Referenced Libraries could be found in the Download section with the following link: * 1. okhttp.jar - https://github.com/square/okhttp * 2. okio.jar - https://github.com/square/okio */ - JavaScript
-
var request = require("request"); var Base64 = require('js-base64').Base64; var encoding = Base64.encode('Functional ID:Password'); var options = { method: 'POST', url: 'https://requesturl/ca/rest/content/v1/model/{modelId}', headers: { 'apiKey' : 'ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=', 'authorization': "Basic " + encoding }, body: { "classifierId": 11 } }; request(options, function (error, response, body) { console.log(body) if (error) throw new Error(error); }); - Python
-
import requests import base64 encoding = base64.b64encode(b'Functional ID:Password') url = "https://requesturl/ca/rest/content/v1/model/{modelId}" headers = { "apiKey" : "ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=", "authorization": "Basic " + encoding.decode("utf-8") } data= { "classifierId": 11 } response = requests.request("POST", url, headers=headers, data=data)
- Example response
-
{ "status": { "code": 0, "messageId": "string", "message": "string" } }