Advanced Configuration : Using Integration Manager APIs : Tutorial : Create a Job Template
 
Share this page                  
Create a Job Template
This section provides steps to create a job template. The parameters it accepts and the response codes are documented at https://api.im.actiandatacloud.com/apidocs/#/Job_Configuration/createJobTemplate.
This is a POST Request and the URL is http://localhost:8080/api/jobtemplates
It accepts application/json as content type and Bearer Token as Authorization and this information should be provided in the header.
Request Header
Content-Type: application/json
Authorization: Bearer <access token value>
It accepts the following request body. The mandatory key that needs to be provided is “name”; replace “string” with the template name. The rest of the keys are optional: either remove them or replace the “string” with valid values or null or empty values.
Request Body
{
    "active": true,
    "destinationId": "string",
    "runtimeConfig": {
        "outMessageNames": [
            "string"
],
        "logLevel": "SEVERE",
        "packageName": "string",
        "inMessages": [
            {
                "body": "string",
                "name": "string",
                "properties": [
                    {
                        "value": "string",
                        "key": "string"
                    }
                ]
           }
    ],
    "macros": [
        {
            "value": "string",
            "key": "string"
        }
    ],
    "entryPoint": "string",
    "packageArtifactOverride": true,
    "packagePrefix": "string",
    "packageVersion": "string",
    "variables": [
        {
            "value": "string",
            "key": "string"
        }
    ]
},
"name": "string",
"description": "string"
}
Here is the sample request that is sent to the API.
Sample Request - HTTP code snippet
POST /api/jobtemplates HTTP/1.1
Host: localhost:8080
Authorization: Bearer <access token value>
Content-Type: application/json
{
    "active": true,
    "name": "sample template",
    "description": "created from API"
}
If the call is successful, status code 201 Created is returned with the following job template response body. You can use the template ID that is returned in the body in other job template and job configuration operations such as updating a job template, while creating a file on a job configuration, while updating a job configuration, and so on.
Sample Response Body for status code: 201
{
    "id": "12ef65ae-9f7e-47cec3dcd1dfa859",
    "name": "sample template",
    "description": "created from API",
    "runtimeConfig": {
        "packageArtifactOverride": false
    },
    "created": "Apr 12, 2019 12:40:04 PM",
    "lastModified": "Apr 12, 2019 12:40:04 PM",
    "active": true,
    "remote": false,
    "href": "http://localhost:8080/api/jobtemplates/12ef65ae-9f7e-47cec3dcd1dfa859",
    "destination": {
        "id": "1"
    },
    "user": {
        "id": "1",
        "name": "admin",
        "href": "http://localhost:8080/api/users/1"
    },
    "createdByUser": {
        "id": "1",
        "name": "admin",
        "href": "http://localhost:8080/api/users/1"
    },
    "lastModifiedByUser": {
        "id": "1",
        "name": "admin",
        "href": "http://localhost:8080/api/users/1"
    }
}
If the call fails due to invalid token or expired token, status code 401 Unauthorized is returned with a message.
Sample Response Body for status code: 401
{
    "error": "invalid_token",
    "error_description": "Cannot convert access token to JSON"
}
If a wrong header or incorrect request body is sent, status code 400 Bad Request is returned.
Sample request with wrong content-type and without mandatory key “name” in the body
POST /api/jobtemplates HTTP/1.1
Host: localhost:8080
Authorization: Bearer <access token value>
Content-Type: Content-Type: application/javascript
{
    "name1": "sample template"
}