Highlighted
Regular Contributor.. Regular Contributor..
Regular Contributor..
795 views

Create REST API to retrieve records from SM table

Hi,

How to create SM REST API to retrieve list of records from specific SM DB table. I managed to create a simple REST API to call the ScriptLibrary. But, not sure on retrieving records from SM Table.

Please advice, thanks

0 Likes
3 Replies
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

Re: Create REST API to retrieve records from SM table

Hello again 🙂

It's really simple to get records via the RESTful API.

As example, I will use the extaccess record "Incident Management".

extacces_im.PNG

As you can see, the RESTful API is enabled for this.

Now you have to call only: http://localhost:13080/SM/9/rest/incidents

In my SOAP UI example, the result is the following:

soapui.PNG

To get the details from an incident, you have to call: http://localhost:13080/SM/9/rest/incidents/IM10001

The result is something like that:

soapui2.PNG

 

Note: i used the "XML" Response in my examples. The JSON Response is the following (for the second screenshot)

{
   "Incident":    {
      "Area": "failure",
      "Assignee": "Change.Analyst",
      "AssignmentGroup": "Application",
      "Category": "incident",
      "ClosedBy": "Incident.Analyst",
      "ClosedTime": "2014-08-14T22:08:17+00:00",
      "ClosureCode": "Diagnosed Successfully",
      "Company": "advantage",
      "Contact": "CAFFREY, AARON",
      "Description": ["Cannot add attachment to OneNote Shared directory."],
      "Impact": "3",
      "IncidentID": "IM10001",
      "JournalUpdates":       [
         "01/15/14 21:05:22 US/Mountain (Jennifer Falcon):",
         "Assign to Lopez"
      ],
      "OpenTime": "2013-12-29T20:02:55+00:00",
      "OpenedBy": "falcon",
      "Phase": "Closure",
      "Service": "CI1001030",
      "Solution": ["Cleanup the backups in document server, free spaces."],
      "Status": "Closed",
      "Subarea": "function or feature not working",
      "Title": "Cannot add attachment to OneNote Shared directory.",
      "UpdatedBy": "xuejun",
      "UpdatedTime": "2015-03-16T23:11:28+00:00",
      "Urgency": "3"
   },
   "Messages": [],
   "ReturnCode": 0
}

 

 

 

The documentation for this can be found here:

https://docs.software.hpe.com/SM/9.52/Codeless/Content/webservicesguide/Consuming_SM_REST_API.htm

 

Hope that helps 🙂

0 Likes
Highlighted
Contributor.
Contributor.

Re: Create REST API to retrieve records from SM table

Hi Marcus, Thanks for the pointers above. We have used same settings as you mentioned as seen in the screenshot below, however, when accessing the SM/9/rest/incidents API endpoint, we get this error:

A CxmlAPIException was raised in native code. error -1. Error in executing script RestfulMain.processResourceError in executing script: Type Error: log has no properties, ReturnCode -1

Screenshot 2018-08-07 13.06.00.png

Please advice. Appreciate your reply. Thanks!!

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: Create REST API to retrieve records from SM table

You started the post by saying you managed to call the ScriptLibrary via REST... What did you mean by that?  Did you by chance modify on OOB script?

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.