RESTFul API - Importing CIs

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 "">localhost:13080/.../" $_.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: "">localhost:13080/.../" or "/computers"

  • 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                                     localhost:13080/.../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: localhost:13080/.../attachments

    Even clicking the link localhost:13080/.../create from localhost:13080/.../ 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.

  • Verified Answer

    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.

  • Hi

    Can u show your powershell script.

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