Cognos Analytics

Cognos Analytics

Connect, learn, and share with thousands of IBM Cognos Analytics users! 

 View Only

How to create a job with REST API

  • 1.  How to create a job with REST API

    Posted Wed November 08, 2023 08:59 AM

    Hello,

    I want to create a simple job with some reports using the REST API. 

    Cognos version is 11.2.4 FP1.

    With curl I created an empty job without an error.

    JSON: 
    {
      "defaultName":"Test Job REST",
      "type":"jobDefinition"
    }


    I see the job in the folder and it looks okay, but when I open the job it is like a new one (name on top says "*New Job").

    With curl I added two times a report as "jobStepDefinition".
    JSON:
    {
      "defaultName":"2023-09-27T12:12:12.000Z",
      "type":"jobStepDefinition",
      "stepObject":
        [
        {
        "searchPath":"/content/folder[@name='aaa']/folder[@name='bbb']/report[@name='ccc']",
        "id":"iD11173C4DB2745C1ABDE7276254498C7",
        "type":"report"
        }
        ]
    }

    By using curl to query the job the output show the two entries I added.
    curl --insecure -X GET -D ctst.hdr -o ctst.out --header "IBM-BA-Authorization: CAM MTsxMDE6MmZiZWJmYjUasdf3NS05Z123LTgzMTQtMDU0MTZkMGM4NmRmOjIwNDY3NTA4MjQ7MDszOzA7" --header "accept: application/json" https://cognos:9300/api/v1/content/iAB73C9411BE543CCB3290728C9C39A8D/items

    Result (by tr , \\n < ctst.out) show the two entries:
    {"content":[{"modificationTime":"2023-11-08T13:11:52.841Z"
    "defaultName":"2023-09-27T11:11:11.000Z"
    "id":"iAB6867CCD5784E7992C5B71DCDB81326"
    "type":"jobStepDefinition"
    "version":1
    "owner":[{"userName":"abc123"
    "defaultName":"abc123"}]
    "links":[{"rel":"self"
    "type":"application/json"
    "href":"/api/v1/content/iAB6867CCD5784E7992C5B71DCDB81326"}
    {"rel":"items"
    "type":"application/json"
    "href":"/api/v1/content/iAB6867CCD5784E7992C5B71DCDB81326/items"}]}
    {"modificationTime":"2023-11-08T13:14:59.787Z"
    "defaultName":"2023-09-27T12:12:12.000Z"
    "id":"iE88A0CD266944C358F42DBF32680940F"
    "type":"jobStepDefinition"
    "version":1
    "owner":[{"userName":"abc123"
    "defaultName":"abc123"}]
    "links":[{"rel":"self"
    "type":"application/json"
    "href":"/api/v1/content/iE88A0CD266944C358F42DBF32680940F"}
    {"rel":"items"
    "type":"application/json"
    "href":"/api/v1/content/iE88A0CD266944C358F42DBF32680940F/items"}]}]}

    But opening the job, I still get the same result (empty job with name "*new job").

    Technically something is working, but it seems I missed one or more parameters in the json specification to make the job specification fully valid.

    Does anyone know what is wrong / missed or have an example / template on how to create a job with REST API?

    Thanks
    Michael



    ------------------------------
    MichaelHaass
    ------------------------------