Highlighted
Honored Contributor.
Honored Contributor.
1387 views

How can I create an incident from an application using Rest Api

Hello,

I want to create incidents in service manager 9.34 as long as a new one is generated in Resilient, an external application.
I have created and configure the external access with the data and allowed actions of the application.
I have already configured in the application the url http:/<ip>:<port>/SM/9/rest/Re_im, to which it will send the incidents.

When I access http:/<ip>:<port>/SM/9/rest/Re_im, it returns a list of service manager incidents and not the list of Resilient incidents.

I do not know what I'm missing so that in service manager the incidents related to the resilient application are created.

I appreciate your help.

Regards,

Juan

0 Likes
4 Replies
Highlighted
Honored Contributor.
Honored Contributor.

Re: How can I create an incident from an application using Rest Api

Hi Juan,

I don't exactly understand what you mean...

If you have successfully created an incident using REST (assuming with the HTTP POST Mode ) the SM returns the created incident in JSON.

After that you can get the incident information using the HTTP GET Mode accessing via http:/<ip>:<port>/SM/9/rest/Re_im/<IM-Number>.

Hope that helps...

Bo

 

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: How can I create an incident from an application using Rest Api

What I need to know is:
How can I create an incident using RESTAPI (POST)?

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: How can I create an incident from an application using Rest Api

Hi Juan,

maybe this is a good starting point: https://community.softwaregrp.com/t5/Service-Manager-Service-Center/Curl-command-for-HPSM-webservices/td-p/949104

I have already created operators via REST using SoapUI (just for testing). If you are still interested I can make some screenshots...

Regards,

Bo

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

Re: How can I create an incident from an application using Rest Api

If you've already configured the extaccess record for REST, you're pretty much there.

The difference is in the methods.  REST uses GET, POST, PUT, DELETE and use that to determine what action Service Manager should take when it gets that method called. 

In your example, navigating to that URL in a web browser invokes the 'GET' method; without passing a specific ticket number at the end of your URL, hitting that URL basically tells Service Manager to show you the key fields (whatever you have mapped in your extaccess record in the Unique Keys array of the RESTful tab).  Appending an IM number (like http://<server>:<port>/SM/9/rest/Re_im/IM12345) will show you the details of that ticket (whatever you have exposed in the 'Fields' tab of the extaccess).

It sounds like what you want to do is POST rather than GET.  On that RESTful tab, you'll see a section for 'Resource Collection Actions' (with a dropdown for what should happen when someone POSTs) and for 'Resource Actions', (with dropdowns for POST, PUT and DELETE).  The values for those dropdowns are based on the values you put in your Allowed Action tab, but they usually get mapped to things like Create (add), Update (save) and Close.  

For example, take a look at an Out of the Box extaccess record like 'IncidentManagement' and you'll see that the Resource Collection Action POST triggers the Create action name (mapped to the 'add' allowed action on the Allowed Actions tab) and the Resource Action for PUT and POST triggers the Update action name (mapped to the 'save' allowed action).

In that example, if someone POSTS a valid JSON object to http://<server>:<port>/SM/9/rest/incidents, that would create a new IM.

To get a sense of what your JSON object should look like, do a GET request to your URL with a specific ticket, and you should get back a specific ticket, structured in the way you'll need to send your data.

I recommend a tool like SOAP UI or other free REST/SOAP tools to test this out so you get a sense of what you need to pass in.

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.