adding journal entries to an incident using web api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2012 08:43 PM
I am trying to use the JSON web API to create incidents in SN and using perl at the moment but I don't think that is relevant to the problem I have.
I can create the incident with out problems and can retrieve it again or look at it from the web interface. What I can't figure out is how to attach journal entries to the incident.
my $result = $self->json_table('incident', '', undef, 'insert', qq|{"short_description":"$short" $category $group, "u_requestor": "$user"}| );
my $number = $result->{'records'}->[0]->{'number'};
pr_object($result->{records}->[0] );
$data = ref $data eq 'ARRAY' ? join("\n", @$data) : $data if defined $data;
$result = $self->json_table('sys_journal_field', 'number', $number, 'update', qq|{"element": "comments" "value" : "$data" }| );
The question is what search clause should I use to link the journal to the incident. I.e. the second and third parameters of the json_table call.
This code does not generate any errors but the journal entries just disappear. I can find them by searching but can't figure out what they are attached to.
Russell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2012 08:20 PM
Now that I have access to the webapi stuff again I am having another bash at getting journal entries inserted into the system and attached to a particular incident.
here is a summary of what is happening now:
create a new incident:
POST http://ws.dev.auckland.ac.nz/servicenow/sandpit/incident.do?JSON&sysparm_action=insert
rc = 200
list the incident returned (most fields deleted for brevity).
...
sys_updated_on: '2012-09-21 02:58:13'
sys_mod_count: '0'
category: 'other/security'
...
sys_updated_by: 'security-incidents'
number: 'INC0010747'
.......
sys_id: '53e8f75af5e87000071a58b4def8758f'
sys_created_by: 'security-incidents'
sys_class_name: 'incident'
opened_at: '2012-09-21 02:58:13'
u_contact_support_location: ''
sys_created_on: '2012-09-21 02:58:13'
u_updated_task: 'false'
state: '1'
order: '0'
..........
then we do a post to try and add some journal entries:
The data for the post:
{"element": "comments", "value" : "test one
test" }
POST http://ws.dev.auckland.ac.nz/servicenow/sandpit/sys_journal_field.do?JSON&sysparm_action=insert&sysparm_query=element_id=53e8f75af5e87000071a58b4def8758f
rc = 200
and json error: Insufficient rights to insert record: sys_journal_field
The user has admin and soap roles.
I have tried both insert and update...
what privs/roles does a user need to update journal fields? or am I doing something wrong in the POST?