Highlighted
Absent Member.
Absent Member.
25663 views

Connecting to HPSM through REST api

Hi all, 

 

I'm new to the REST api I was wondering where I can find:

 

1) The documentation for using REST api in Java to connect to HPSM ticketing database?

 

2)Where can I find the configuration settings to connect to my HPSM?

 

Any help would be much appreciated.

 

Kind Regards, 

Mark

Tags (4)
0 Likes
11 Replies
Highlighted
Established Member..
Established Member..

Re: Connecting to HPSM through REST api

Hey, simply sign in to http://softwaresupport.hp.com and down load the Web Services manual for the version you are on.

 

Here is a link to 9.34 document:-

 

https://softwaresupport.hp.com/group/softwaresupport/search-result/-/facetsearch/document/KM01043337

 

It's best to setup a seperate port for web service connections.

 

Details are all in the manual.

 

REST services can be set up via the extaccess records in the application.

 

 

0 Likes
Highlighted
New Member.

Re: Connecting to HPSM through REST api

I am using HPSM rest api to post incident and retirieving incidents, but when i invoke post(save incident) service through java with HTTP URL Connection,  Initially it is taking nearly 5 mins for creatign incident, and then it is taking 30 secs for saving incident, 10 secs form retrieving incidents.

My client(java application) is reciding in different machine and hpsm is installed in different machine.

I am using Normal java code to connect hpsm.

URL url = new URL("<HPSM URL Located in remote machine>");
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
		conn.setRequestMethod("GET Or POST");
		conn.setRequestProperty("Accept", "application/json");

 It would be appreciable, if any one provide solution.

Thanks.

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Connecting to HPSM through REST api

@Balaji_HP

Maybe its a network issue. I am guessign that since you told both applications are on different box. 

How about a continuous ping to the HPSM server ?

Also check if any anti-virus is runnign in HPSM server.

AB

Kindly assign kudos if the post is helpful!
Highlighted
New Member.

Re: Connecting to HPSM through REST api

Hey thanks for your quick reply after first connection and posting incident info, for second onwards it is taking 30 secs. it has reduced from 5mins to 30 secs, even though it is big change,  30 secs also long duration and for retrieving it is taking nearly 9 secs.

0 Likes
Highlighted
New Member.

Re: Connecting to HPSM through REST api

hi abhin88,

I have one question regarding hpsm rest service cookies, i am tring to use hpsm connection effectively for that i need to get cookie

jsessionid from httpurlconnection response. but i am getting null that rest service is returning nothing in cookies.

Is there any way to get cookie from hpsm rest service.

Tags (1)
0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Connecting to HPSM through REST api

Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Connecting to HPSM through REST api

@KingMark,

Following code works for me with user/password: falcon/1

Get an incident by java:

 

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/IM10002");
        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();
    }
}

To create a new incident by java:

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");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setDoOutput(true);
        conn.setRequestProperty("Content-Type", "application/json");
        conn.setRequestProperty("Accept-Encoding", "gzip,deflate");
        conn.setRequestProperty("Authorization", "Basic ZmFsY29uOjE=");
        String input = "{ \t'Incident': \t{       'AlertStatus' : 'updated',       'Area' :'failure',       'Assignee' : 'Incident.Analyst',       'AssignmentGroup': 'Network',       'Category' : 'incident',       'ClosureCode' : 'Solved by Workaround',       'Company' : 'advantage',       'Contact' : 'FALCON, JENNIFER',       'ContactFirstName' :'FALCON',       'ContactLastName' : 'JENNIFER',       'Description' : [ 'test' ],       'Impact' : '2',       'JournalUpdates':  \t    [ '08/04/08 12:54:14 US/Mountain (falcon):',           'test',           '08/04/08 12:54:14 US/Mountain (falcon):',           'test'         ],       'Location':'advantage/North America',       'OpenTime' : '2007-09-02T07:51:00+00:00',       'OpenedBy':'Jurr.Fleijs',       'ProblemType' : 'incident',       'ResolutionFixType' : 'incident',       'SLAAgreementID' : 168,       'Service' : 'CI1001060',       'SiteCategory' : 'incident',       'Solution' : ['Solution by rest api'],       'Status' : 'Work In Progress',       'Subarea' :'function or feature not working',       'TicketOwner' : 'Jurr.Fleijs',       'Title' : 'test',       'UpdatedBy' : 'problem',       'UpdatedTime' : '2008-08-04T12:54:26+00:00',       'Urgency' : '3',       'UserPriority': '3 - Average',       'explanation' : ['test'],       'folder' :'advantage' \t} }";
        OutputStream os = conn.getOutputStream();
        os.write(input.getBytes());
        os.flush();
        //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

 

 

Highlighted
New Member.

Re: Connecting to HPSM through REST api

Hey Ling-Yan,

Thanks for your help on rest service connection. I did everything with hpsm rest sevice and integrate with my application succesfully. Un fortunately i have only 15 session to connect hpsm but my application has 20 concurrent users. Here i planned to get cookies from urlconnection and store in cache. when end user calls the api i am sending cookie in header of url connection. 

Note: Here i am using Basic Authentication(different user) for get the different  cookies(Not Authenticator.setDefault)

In my response header fields i can see only one cookie(i.e Set-Cookie: JSESSIONID=576SSDSDS657  /sm)

While sending cookie to another url with out authorisation i am getting 401 (UnAuthorised) error.

Please help me on this to reuse the session. so that i can use 15 session is very effectively. 

Tags (3)
0 Likes
Highlighted
New Member.

Re: Connecting to HPSM through REST api

HI Can any one reply for this post.

0 Likes
Highlighted
New Member.

Re: Connecting to HPSM through REST api

Hi lingyanmeng,

Is there any option to persistance sessions with hpsm rest(http) service. if yes please let me know the procedure how achieve it.

i am using HttpUrlConnection for accesing rest service in java.

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

From run command, opening HPSM server , unable to access the logview folder

Hi 

i am trying to open the server from run command, i can view the logview folder but when open the logview to aceess showing error: windows cannot acess \\       \\logview

 

Please let me know how to give acess to myself or to some other person facing the same issue

PFAAcess.JPG

 

 

 

Tags (1)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.