Rest api for Retreive incidents in the range of dates

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

Tags:

  • Following code works for me with username/password: falcon/1

    curl -XGET -H "Authorization: Basic ZmFsY29uOjE=" -H "Accept-Encoding: gzip,deflate" "">localhost:13951/.../incidents

    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("">localhost:13951/.../incidents
            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

  • Thanks for your quick response, It's  working fine. But When i send the below req, it is getting all the incidents maches with first condition
    and second condtion. I am not getting incident in between thosed dates i am all records. is it possible to get incident in between those
    two dates.
     
    localhost:13951/.../incidents &view=expand

     

  • Verified Answer

    Try following code, it works for me:

    curl -XGET -H "Authorization: Basic ZmFsY29uOjE=" -H "Accept-Encoding: gzip,deflate" "localhost:13951/.../incidents and OpenTime<'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("localhost:13951/.../incidents and OpenTime<'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

     

     

  • 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.

     

     

  • @Balaji_HP,

    You can get all the values by adding the view=expand:

     

    curl -XGET -H "Authorization: Basic ZmFsY29uOjE=" -H "Accept-Encoding: gzip,deflate" "localhost:13951/.../incidents and OpenTime<'12/12/2016'&view=expand"

    And the mapping is in the web service configuration

     

     

    for more information, check the help:

    http://docs.software.hpe.com/SM/9.50/Codeless/Content/integrations/web_services/concepts/web_services.htm

    Let me know if it helps,

    Ling-Yan

     

  • @Balaji_HP,

    You can get all the values by adding the view=expand:

     

    curl -XGET -H "Authorization: Basic ZmFsY29uOjE=" -H "Accept-Encoding: gzip,deflate" "localhost:13951/.../incidents and OpenTime<'12/12/2016'&view=expand"

    And the mapping is in the web service configuration

     

     

    for more information, check the help:

     http://docs.software.hpe.com/SM/9.50/Codeless/Content/integrations/web_services/concepts/web_services.htm

    Let me know if it helps,

    Ling-Yan

     

  • Hi
     
    Thanks for your valuable time spent for my interactions. I need one more api to approve and deny tickets.
    What's my requirement is, As of now i am displaying all tickets to approve for manager, now i need  a rest service
    to approve/deny the ticket(interaction)  along with comments.
    Please let me know if you have any rest service for the above requirement.
     
     
    Regards
  • @Balaji_HP,

    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

  • 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.