NOTICE: Branded Content
NOTICE: 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.
Performance Center User Discussions
cancel

REST API Functionality Query

SOLVED
Go to solution
Highlighted
Outstanding Contributor.. cmcn2016 Outstanding Contributor..
Outstanding Contributor..

REST API Functionality Query

One of our end users is trying to get REST API functionality working in our Performance Center v12.55

Basically he needs to be able to make requests like small web service requests to certain URL's that are supposed to be availble in Performance Center.

e.g. 

http://performancecenter/Admin/rest/v1/authentication-point/authenticate

He is appending specific URL paths on to the end of the main Performance Center URL but keeps getting a 'Not Found' error.

Is there something which needs to be done on the admin side to facilitate such requests?

1 ACCEPTED SOLUTION

Accepted Solutions
Trusted Contributor.. sarraulteos Trusted Contributor..
Trusted Contributor..
Solution

Re: REST API Functionality Query

To be able to send REST calls you need to install a REST client. In this article, we will use Postman (https://www.getpostman.com/).

A REST call consists of several parts: HTTP Method, URL, Headers, and Body (there are more but let’s concentrate on the most important ones). See the Performance Center REST API documentation for the URL, HTTP Method, Header, and Cookie to use for each REST call, and the format of the request body (if it is required).

The method can be GET, POST, PUT, DELETE and PATCH. Note: GET and POST are the mostly commonly-used (see the API documentation for the differences between them, and when to use each method).

Let’s now make the following REST calls using the Performance Center REST API:

  1. User authentication
  2. Run performance test

 User authentication using the Performance Center REST API

Every Performance Center REST session should start with the authentication REST call.

To create the authentication request header, encode the string "<user name>:<password>" using Base64. For details, see the Authenticate call in the PC REST API documentation.

Now let’s open Postman, build a REST call, and execute it:

  1. Select the GET
  2. For the URL, enter the address of your Performance Center server.
  3. Click the Headers tab, and add a new header: type “Authorization” at Key column and paste the value from the Base64 encoder at Value  
  1. Click Send. The following response is displayed: 

 

The response status should be “200 OK”.

The response contains the cookies: “LWSSO_COOKIE_KEY” and “QCSession”. These cookies are required for every subsequent Performance Center REST call. Note: Postman automatically adds them to every request.

 Start a performance test run using the Performance Center REST API

To start a performance test, you need to know the Test ID and Test Instance ID of the test you are about to run. The easiest way to get this information is to log on to the Performance Center project, open the Test Plan view, and select the test.

The Test ID appears in parenthesis next to the Test name:

 

Scroll to the bottom of the General Details list, and click the Assign To: link. The Test Instance ID is displayed in the Assign and Select Test Set dialog box:

 Now we are ready to build a REST call:

  1. Select the POST
  2. For the URL, enter the name of the domain and project that contains the test which you plan to run.
  3. Click the Headers tab, and add Content-Type: application/xml. Content-Type describes the format of the data you are sending to the Performance Center server.  
  1. Click the Bodytab, and enter XML describing the requested run. Use the Test ID and Test Instance ID         you found earlier:

<Run xmlns="http://www.hp.com/PC/REST/API">
 <PostRunAction>Collate And Analyze</PostRunAction>
 <TestID>2</TestID>
 <TestInstanceID>2</TestInstanceID>
 <TimeslotDuration>
 <Hours>0</Hours>
 <Minutes>30</Minutes>
 </TimeslotDuration>
 <VudsMode>false</VudsMode>
</Run>

  1. Click Send.

           The response status should be “201 Created”.

The response body contains XML describing the test run. The run ID is “35” and the current run state is “Initializing”.

You can get the run state by using Performance Center REST API call “Get Run Status”. For details, see the PC REST API documentation

In this REST call, you need to provide the Run ID that you obtained from the previous step:

The run state is currently “Running” (in the previous call it was “Initializing”). Seeing this update means the performance test started successfully.

You can keep executing this REST call until the run state becomes “Before Collating Results”. Since the post-run action is “Do Not Collate”, getting a run state of “Before Collating Results” means that the test has finished:

 

For details on how to run a performance test using the Performance Center REST API, see Start a Test Run in the PC REST API documentation.

For more information, visit our online PC REST API documentation

3 REPLIES
Trusted Contributor.. sarraulteos Trusted Contributor..
Trusted Contributor..
Solution

Re: REST API Functionality Query

To be able to send REST calls you need to install a REST client. In this article, we will use Postman (https://www.getpostman.com/).

A REST call consists of several parts: HTTP Method, URL, Headers, and Body (there are more but let’s concentrate on the most important ones). See the Performance Center REST API documentation for the URL, HTTP Method, Header, and Cookie to use for each REST call, and the format of the request body (if it is required).

The method can be GET, POST, PUT, DELETE and PATCH. Note: GET and POST are the mostly commonly-used (see the API documentation for the differences between them, and when to use each method).

Let’s now make the following REST calls using the Performance Center REST API:

  1. User authentication
  2. Run performance test

 User authentication using the Performance Center REST API

Every Performance Center REST session should start with the authentication REST call.

To create the authentication request header, encode the string "<user name>:<password>" using Base64. For details, see the Authenticate call in the PC REST API documentation.

Now let’s open Postman, build a REST call, and execute it:

  1. Select the GET
  2. For the URL, enter the address of your Performance Center server.
  3. Click the Headers tab, and add a new header: type “Authorization” at Key column and paste the value from the Base64 encoder at Value  
  1. Click Send. The following response is displayed: 

 

The response status should be “200 OK”.

The response contains the cookies: “LWSSO_COOKIE_KEY” and “QCSession”. These cookies are required for every subsequent Performance Center REST call. Note: Postman automatically adds them to every request.

 Start a performance test run using the Performance Center REST API

To start a performance test, you need to know the Test ID and Test Instance ID of the test you are about to run. The easiest way to get this information is to log on to the Performance Center project, open the Test Plan view, and select the test.

The Test ID appears in parenthesis next to the Test name:

 

Scroll to the bottom of the General Details list, and click the Assign To: link. The Test Instance ID is displayed in the Assign and Select Test Set dialog box:

 Now we are ready to build a REST call:

  1. Select the POST
  2. For the URL, enter the name of the domain and project that contains the test which you plan to run.
  3. Click the Headers tab, and add Content-Type: application/xml. Content-Type describes the format of the data you are sending to the Performance Center server.  
  1. Click the Bodytab, and enter XML describing the requested run. Use the Test ID and Test Instance ID         you found earlier:

<Run xmlns="http://www.hp.com/PC/REST/API">
 <PostRunAction>Collate And Analyze</PostRunAction>
 <TestID>2</TestID>
 <TestInstanceID>2</TestInstanceID>
 <TimeslotDuration>
 <Hours>0</Hours>
 <Minutes>30</Minutes>
 </TimeslotDuration>
 <VudsMode>false</VudsMode>
</Run>

  1. Click Send.

           The response status should be “201 Created”.

The response body contains XML describing the test run. The run ID is “35” and the current run state is “Initializing”.

You can get the run state by using Performance Center REST API call “Get Run Status”. For details, see the PC REST API documentation

In this REST call, you need to provide the Run ID that you obtained from the previous step:

The run state is currently “Running” (in the previous call it was “Initializing”). Seeing this update means the performance test started successfully.

You can keep executing this REST call until the run state becomes “Before Collating Results”. Since the post-run action is “Do Not Collate”, getting a run state of “Before Collating Results” means that the test has finished:

 

For details on how to run a performance test using the Performance Center REST API, see Start a Test Run in the PC REST API documentation.

For more information, visit our online PC REST API documentation

Agam
Visitor.

Re: REST API Functionality Query

Hi,

I followed the steps mentined in this article and the steps mentioned in 

https://admhelp.microfocus.com/pc/en/12.55/api_refs/Performance_Center_REST_API/Performance_Center_REST_API.htm

I am able to make a succesful authentication call while failing at every other call post that!. with '1001 - Operation Failed' error.

Is there something very obivious I am missing?

I have tried different api's call with Postman and Python 

Micro Focus Expert
Micro Focus Expert

Re: REST API Functionality Query

Hi  Agam,

Can you share a specific request that fails?
Please include the request header and body.

Regards,
Eyal