Menu

Adding CIs to Tickets via rest api

isaac
2015-01-19
2016-11-20
  • isaac

    isaac - 2015-01-19

    Hi, I would like to create tickets via the rest api. It works in general, but I do not see how to add CIs to the ticket. Here is what I have:

    json_request = {
    'operation': 'core/create',
    'class': 'RoutineChange',
    'output_fields': 'ref, title',
    'fields': {
        'org_id': 'SELECT Organization WHERE name = "My org"',
        'title' : 'Deploy plugin for Foobar',
        'description': 'Deploy plugin as defined in xzy.',
          },
    'comment': 'created automatically by script'
    }
    

    (this is python which will be converted to json).

    How can I add CIs to the ticket via rest api? Also, how can I assign an agent?

     

    Last edit: isaac 2015-01-19
  • Jaime Valero

    Jaime Valero - 2015-01-19

    Hi Isaac :

    To link CI's to a ticket, you should create objects of class lnkFunctionalCIToTicket.
    I do not use the api rest to create objects, but I think it very similar to the json you printed.

    Also, to assign an agent, I think you should use an operation of type 'core/update'.

    Good luck. Regards

     

    Last edit: Jaime Valero 2015-01-19
  • stade13

    stade13 - 2015-01-19

    In the first, you can receive your ci:

                $aOperations = array(
                        array(
                        'operation' => 'core/get', // operation code
                        'class' => 'FunctionalCI',
                        'key' => 'SELECT FunctionalCI WHERE id = 1',
                        'output_fields' => 'id, name', // list of fields to show in the results (* or a,b,c)
                        )
                );
    

    After add result in your array

    json_request = {
    'operation': 'core/create',
    'class': 'RoutineChange',
    'output_fields': 'ref, title',
    'fields': {
    'org_id': 'SELECT Organization WHERE name = "My org"',
    'title' : 'Deploy plugin for Foobar',
    'description': 'Deploy plugin as defined in xzy.',
    'functionalcis_list' => $functionalCi,

      },
    

    'comment': 'created automatically by script'
    }

     
  • isaac

    isaac - 2015-01-19

    Hi Jaime,

    cool, that helped, thank you!
    For the assignment, its actually an operation of type 'core/apply_stimulus'.

    I have attached an example python script, which creates a RoutineChange, adds a CI and assigns it to an agent, Supervisor and Manager. If anyone feels this could be usefull to them, feel free to use it.

     
  • Denis

    Denis - 2015-01-19

    I'm pretty sure you can create the RoutineChange and assign CIs to it in one operation. I have to double-check the syntax, but you may try something like:

    json_request = {
    'operation': 'core/create',
    'class': 'RoutineChange',
    'output_fields': 'ref, title',
    'fields': {
        'org_id': 'SELECT Organization WHERE name = "My org"',
        'title' : 'Deploy plugin for Foobar',
        'description': 'Deploy plugin as defined in xzy.',
        'functionalcis_list' => [
                { functionalci_id: 'SELECT FunctionalCI WHERE id= 42' },
                { functionalci_id: 'SELECT FunctionalCI WHERE id= 57' },
                { functionalci_id: 'SELECT FunctionalCI WHERE name= "foo"' },
            ],
          },
    'comment': 'created automatically by script'
    }
    
     

    Last edit: Denis 2015-01-19
  • Jaime Valero

    Jaime Valero - 2015-01-19

    Hi Isaac:

    Thank you for the script. It is very useful for me to have an example!.

    Regards

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.