It is not possible to download an attachment via webservice. We need a method to do this. We want transfer a ticket to another system.
We were looking to do the same and in the end wrote a java client using a mixture of soap based web service calls and a call to the upload servlet to achieve this grammatically so that we could download an attachment within an ITPAM process and then attach to a request being sent to a 3rd party helpdesk. It would be much better if this was supported in the SDM SOAP api like uploading attachments are. I wonder if this could be achieved via the 12.9 RESTful API somehow?
If you can use the RESTful api then I think the tech reference guide (Section 7 - REST Java Sample Code - Managing Attachments for Tickets) has some examples of using that to download attachments also. There is a sample app with a java client file (SampleDownloadAttachment.java) which also gives a full example of this.
You can use ca upload servlet to download the files. All you need is to construct the following link
http://hostname:8080/CAisd/UploadServlet?AttmntId=" + attmntId + "&Bpsid=" + bopsid + "&retURL=http://hostname/CAisd/pdmweb.exe?SID=" + sid + "+FID=" + new Random().nextInt() + "+OP=DISPLAY_FORM+HTMPL=attmnt_download_done.htmpl&ServerName=hostname
bopsid and attmntId can be received from WS calls
Could you help me? I'm tried test the getBopsid method but in all tests I got a error message...
I used this call:
In Technical Reference Guide I saw that this "contact" parameter is not a contact name, but the system name. I understood that it is userid. Is it rigth?
Yes you should use userid to get bop_sid
Sent from my iPhone
Userid is correct. First perform a login to get the sid and then getbopsid using that sid and the original userid.
Ferdinand, Is that test patch available? We have a support case open regarding the Restful api for downloading attachments not currently working. The last update I saw on that was that it was with Sustaining Engineering for investigation / patch.
I should have checked the case first Looks like we now have the test patch.
I had tested with ServiceDesk, the method returned error, when I used another user the method worked fine.
This is marked delivered but i don't see this functionality created yet? Whats the status on this? I can create the link but it fails when i try to make proc auto digest it via the web get operator.
I think it is delivered as part of the REST based webservice functionality.
The rest functionality allows you to create and delete attachments but not retrieve them.
Hmm, I never tried it by myself, just trusted what I saw: Take a look at $NX_ROOT/samples/sdk/rest/java/test3_attachments/SampleDownloadAttachment.java
Hey Michael... Im migrating a solution that actually uses rest to pull attachment data. I'm getting the following error. Any Ideas?
Error while executing request or processing HTTP response. class java.lang.IllegalStateException. Unsupported authentication scheme: Negotiate
Sorry. but I have no idea.
The only thing I have in mind, and as far I undestand the context: The authentaction scheme "Negotiate", is someting the Server tells the Client, how to authenticate.
I'm wondering , because this is something windows specific , and not something sdm supports ootb, as far as I know.
How do you authenticate against the rest webservice ?
Figured it out. The out of the box soap operators point to http. I had to go into their operator definition and update them to https. Thanks Michael!
Hi, using REST i followed the SampleDownloadAttachment.java ditto ..but getting "500 Internal Server Error" ...and failing to download. My env is CA SDM 14.01 CU 3, Windows 2012 R2
Anybody tried it using REST and successful?
assuming 41234123 is a valid attachment record id, it worked for me (17.0) using :
and of course sending header X-AccessKey with a valid access key
Hope this helps
thanks for response. I tried the same thing (GET /caisd-rest/attmnt/400015/file-resource) with valid X-AccessKey header. That is the only header i passed in http-request. ..but i got response code 500, with Internal Server Error as message...
Can you help me with these two things in your environment?
1. in response headers, did you get the [Content-Disposition] header, which contains the file name? or you directly took the BufferedInputStream from response entity? I'm using httpclient 4.5.2
2. How did you get the attmnt id value? as in, which http call you made to get the attachment ids? In my case, i sent X -Obj Attrs in headers as 'attachments' for a GET request on an incident (caisd-rest/in/400023) which gives me a xml with collection of (lrel) attachments link which has ID of lrel with href/url of each lrel object (in case if there are two attachments)... but i'm clueless as to how to get the attachment ID next. However for testing, I found the attachment ID from database attmnt table.
Anyway, because I cannot see what you are doing different to me, your problem might be version related...
I also think if the source SampleDownloadAttachment.java is available in your installation, I assume your version is intended to work regarding attachment download via REST. That means if it doesn't, its worth a support issue.Kind regards
Sorry didn't escaped the equal signs... :
.../caisd-rest/attmnt?WC=requests.cr.ref_num%3D'your incident number here'
.../caisd-rest/attmnt?WC=changes.chg.chg_ref_num%3D'your change number here'
Much thanks for that tip Michael...[/caisd-rest/attmnt?WC=requests.cr.ref_num%3D'your incident number here'] where do we get the documentation for all these urls? I'll try this one out at earliest. The online documentation doesnt have this url, , and for extra docs it says to use pdm_rest_util.cmd –undeploy / deploy with the doclets jar file. I'm yet to do that in my Test env.
Secondly, this URL is for Incident or Request?
And yes, I have opened a ticket with support as well.
Hi Michael, I got the attachment IDs with the url that you shared, thanks!
However I'm still getting the same "500 - Internal Server Error" in the response.
In the jrest.log file I got this message against my attachment id. Any idea why this should come?
11/17 14:52:38.713 [http-bio-8050-exec-3] ERROR FileUploadUtils ? Exception error on file download operation for attmnt id(1562981). com.ca.sdm.bop.BPMessagingException: AHD04043:The user name or password you entered is not correct. Please try again.
I'm sorry, but I have no idea, about the background of this message. Maybe your findings are a good hint for our support guys.
regarding your earlier question: The REST Service is based on some principals: each table is mapped to a factory name, which can be accessed as a REST resource with /caisd-rest/factory_name
of course an Administrator can restrict the list of exposed factories/tables.
each record has a unique id (mostly integer,sometimes uuid) so you can easaly access a record content by its id doing a GET to /caisd-rest/factory_name/id
this is descibed in :
even the wherclause based search is described there.
a good staring point for understandning how object whereclauses works, you can find here:
Retrieving data ...