

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi, I have integrated rest full api with my application successfully, now i have one requiremnt where i have to get the incidents in the range of dates. I have search for the query lot, but no luck.
Example: have to get list of all closed incidents in between 1st Feb to 5th Feb .
Can any one help me to acheive the same.
Thanks
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Try following code, it works for me:
curl -XGET -H "Authorization: Basic ZmFsY29uOjE=" -H "Accept-Encoding: gzip,deflate" "http://localhost:13951/SM/9/rest/incidents?OpenTime>'11/25/2015'%20and%20OpenTime<'12/12/2016'"
or java code:
package com.company; import java.io.*; import java.net.*; public class Main { public static void main(String[] args) throws IOException { URL url = new URL("http://localhost:13951/SM/9/rest/incidents?OpenTime>'11/25/2015'%20and%20OpenTime<'12/12/2016'&view=expand"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept-Encoding", "gzip,deflate"); conn.setRequestProperty("Authorization", "Basic ZmFsY29uOjE="); //conn.getResponseCode(); BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { System.out.println(output); } conn.disconnect(); } }
Ling-Yan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Following code works for me with username/password: falcon/1
curl -XGET -H "Authorization: Basic ZmFsY29uOjE=" -H "Accept-Encoding: gzip,deflate" "http://localhost:13951/SM/9/rest/incidents?OpenTime>'11/25/2015'&view=expand"
And following java code works for me as well:
package com.company; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.*; public class Main { public static void main(String[] args) throws IOException { URL url = new URL("http://localhost:13951/SM/9/rest/incidents?OpenTime>'11/25/2015'&view=expand"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept-Encoding", "gzip,deflate"); conn.setRequestProperty("Authorization", "Basic ZmFsY29uOjE="); //conn.getResponseCode(); BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { System.out.println(output); } conn.disconnect(); } }
And for more syntax, you can reference to the url Tom mentioned.
Let me know if it helps,
Ling-Yan


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
http://localhost:13951/SM/9/rest/incidents?OpenTime>'11/25/2015'&OpenTime<'11/27/2015' &view=expand

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Try following code, it works for me:
curl -XGET -H "Authorization: Basic ZmFsY29uOjE=" -H "Accept-Encoding: gzip,deflate" "http://localhost:13951/SM/9/rest/incidents?OpenTime>'11/25/2015'%20and%20OpenTime<'12/12/2016'"
or java code:
package com.company; import java.io.*; import java.net.*; public class Main { public static void main(String[] args) throws IOException { URL url = new URL("http://localhost:13951/SM/9/rest/incidents?OpenTime>'11/25/2015'%20and%20OpenTime<'12/12/2016'&view=expand"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept-Encoding", "gzip,deflate"); conn.setRequestProperty("Authorization", "Basic ZmFsY29uOjE="); //conn.getResponseCode(); BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { System.out.println(output); } conn.disconnect(); } }
Ling-Yan


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hey thanks for your help. It worked.
And one more question is, Is it possible to get Additional fields(to display in UI) with respect to Category, Area, SubArea through rest service. If it is not possible how can i get addition fields from HPSM data base.
Where these additional fiels will stay and what is the mapping behind it. if possible please send me the link to get the information.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
You can get all the values by adding the view=expand:
curl -XGET -H "Authorization: Basic ZmFsY29uOjE=" -H "Accept-Encoding: gzip,deflate" "http://localhost:13951/SM/9/rest/incidents?OpenTime>'11/25/2015'%20and%20OpenTime<'12/12/2016'&view=expand"
And the mapping is in the web service configuration
for more information, check the help:
Let me know if it helps,
Ling-Yan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
You can get all the values by adding the view=expand:
curl -XGET -H "Authorization: Basic ZmFsY29uOjE=" -H "Accept-Encoding: gzip,deflate" "http://localhost:13951/SM/9/rest/incidents?OpenTime>'11/25/2015'%20and%20OpenTime<'12/12/2016'&view=expand"
And the mapping is in the web service configuration
for more information, check the help:
Let me know if it helps,
Ling-Yan


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I believe you got the idea on the restful API. And you can find more syntex in the help server.
I don't have an API in hand now.
Ling-Yan


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hey Lingyanmeng,
Sorry for asking again, After having look at google, i got below api for approval.
<server>:<port>/SM/9/rest/changes/{header,number}/action/approve.
I am listing all pending incidents(having ChangeID) from below rest service
<server>:<port>/SM/9/rest/changes?current.pending.groups=<EMPID>&ApprovalStatus=pending&view=expand
So now i have to give option to approve for EMPID(Manager), I dont know what is header,number but i have set that as ChangeId and i called following rest service
<server>:<port>/SM/9/rest/changes/<ChangeId>/action/approve?current.pending.groups=<EMPID> with follwing request Body
{ "Change": {
"approve":{
"ApprovalComments":"Approveal Comments tested"
}
}
}
but i am getting follwoing message as exception
Messages": [
"You may not approve for any of the pending approval groups.",
"The following values are ignored:{\"approve\":{\"ApprovalComments\":\"Approveal Comments tested\"}}"
],
"ReturnCode": 28
Please help me to achieve the approval process.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
The user your rest call has logged in with do not have permisisons to approve. You need to ensure that this user has the proprt permissions.