RESTful API - Attachments for Incident (483 Views)
Reply
Frequent Advisor
abhin88
Posts: 74
Registered: ‎01-07-2013
Message 1 of 3 (483 Views)

RESTful API - Attachments for Incident

Hello Experts

 

I am quite new to RESTful. We have configured REStful for incidents, service requests and problem. I would like to know how I can add attachments for the same.

 

The current setup is 

 

1. There is an User portal from there incidents or service requests are created.

2. Users may want to attach these tickets which will be pushed to SM

3. The attachments should be available in Service Manager side as well.

 

Any help would be much appreciated.

 

Abhinav

 

Please use plain text.
HP Expert
lisajo
Posts: 480
Registered: ‎02-15-2010
Message 2 of 3 (449 Views)

Re: RESTful API - Attachments for Incident

Hi

Not sure if this will help or not but there is a discussion

 

http://h30499.www3.hp.com/t5/HP-Service-Manager-Service/Attachment-and-Webservice/td-p/5354705#.UyL0...

"HP Support
If you find that this post or any post resolves your issue, please make sure to mark it as an accepted solution."
Please use plain text.
Occasional Advisor
MT03
Posts: 8
Registered: ‎10-31-2011
Message 3 of 3 (387 Views)

Re: RESTful API - Attachments for Incident

Hi,

 

yeah it's a good question - i spent some hours and found a solution.

 

I have tested with HPSM 9.33.0035 (WIN).

To simulate your external user portal, i have used soapUI in version 5.0.0.

 

My latest configuration is the following:

 

Method: POST

Endpoint: http://127.0.0.1:13080

Resource: /SM/9/rest/interactions/<your-interaction-id>/attachments

 

As Post Body, i have the following JSON Code (but i think, the post body is not required)

 

{
   "attachments" : [
   {
      "attachment" : {
         "name" : "soapui.log"
      }
   }]
}

 

 

I have attached an attachment in soapUI, named "soapui.log".

The Attachment is cached in my example.

The Content-Type of the attachment is "application/octet-stream".

 

Now the important part :)

 

You have to set a Header key named "Content-Dispostion".

The Value of this header is "attachment; filename=soapui.log"

 

The second Header key is "Content-Type".

The value of this header is "application/octet-stream" (without this, your attachment gets "application/json" as content-type.

 

Now, if you send your request to the HPSM, you should get the following response:

 

{
"Messages": [],
"ReturnCode": 0,
"attachment": {
"href": "cid:53467b610011401020594248",
"len": 85,
"name": "soapui.log",
"type": "application/octet-stream",
"xmime:contentType": "application/octet-stream"
}
}

 

 

Without the header (Content-Disposition) you will get something like this

 

{
"Messages": ["Attachment name is required."],
"ReturnCode": 71
}

 

 

I have attached some screenshots, which explains it in pictures ;)

 

 

Hope this helps.

 

 

Greets!

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation