Our vBulletin migration is complete.
Welcome vBulletin users! All content and user information from the Micro Focus Forums (vBulletin) site has been migrated to this site. READ MORE.
Super Contributor.. EvskiL Super Contributor..
Super Contributor..
1181 views

RESTFul API - Importing CIs

Jump to solution

Hi Experts,

I am having a small issue with using the RESTFul API to import my list of CIs into HP Service Manager.

I am using a Powershell script to create the list for each Device in my XML file, but the issue I am having is in regards to the URI "http://localhost:13080/SM/9/rest/devices/"+$_.objid+"/action/create" when trying to create the CIs.

It gives me a error of: 

{
  "Messages": ["Key word \"attachments\" is missing."],
  "ReturnCode": 71
}

Do I need a attachment to create a CI? If so what should I be attaching? - Also how do I know which ServiceName is correct for what I want, as there are Computers, Devices, Display Devices, etc. that all return the same list of configuration items when I use the GET equivalent: "http://localhost:13080/SM/9/rest/devices/" or "/computers"

0 Likes
1 Solution

Accepted Solutions
Super Contributor.. EvskiL Super Contributor..
Super Contributor..

Re: RESTFul API - Importing CIs

Jump to solution

Solution to this is I need to pass a POST Method in the header.

This will also require you to pass the Content-Type in the header as well.

 

This could be done for example in a Powershell Script using Invoke-WebRequest:

Invoke-WebRequest -Uri $hpsmuri -Credential $credentials -Method Post -ContentType "application/json"

Now I just have convert my input to JSON to work with HPSM.

0 Likes
3 Replies
Highlighted
Super Contributor.. EvskiL Super Contributor..
Super Contributor..

Re: RESTFul API - Importing CIs

Jump to solution

Following the WebServices Document and checking my External Access Definitions the following should work fine following the OOB:

Supported actions:

Action name:                 Supported Methods:            URI:

Create                            POST                                     http://localhost:13080/SM/9/rest/computers/{logical.name}/action/create

But for some reason it believes I am trying to GET following this format:

Resource type: Resource Attachment Collection

Supported Methods: GET/POST/DELETE

URI: http://localhost:13080/SM/9/rest/computers/{logical.name}/attachments

Even clicking the link http://localhost:13080/SM/9/rest/computers/{logical.name}/action/create from http://localhost:13080/SM/9/rest/#computers gives me the same error as the original post:

{
  "Messages": ["Key word \"attachments\" is missing."],
  "ReturnCode": 71
}

Should this be occuring? I would like to get this working so I can save myself from manually inputting everything all the time.

0 Likes
Super Contributor.. EvskiL Super Contributor..
Super Contributor..

Re: RESTFul API - Importing CIs

Jump to solution

Solution to this is I need to pass a POST Method in the header.

This will also require you to pass the Content-Type in the header as well.

 

This could be done for example in a Powershell Script using Invoke-WebRequest:

Invoke-WebRequest -Uri $hpsmuri -Credential $credentials -Method Post -ContentType "application/json"

Now I just have convert my input to JSON to work with HPSM.

0 Likes
tknrng
New Member.

Re: RESTFul API - Importing CIs

Jump to solution

Hi

Can u show your powershell script.

I got error - a JSONObject text must begin with '{' at character 0"]

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.