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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
$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'
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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:
(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
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
In the first, you can receive your ci:
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'
}
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.
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:
Last edit: Denis 2015-01-19
Hi Isaac:
Thank you for the script. It is very useful for me to have an example!.
Regards