Idea Details

Download attachment via webservice

Last activity 06-13-2019 10:03 AM
HeikoMittelstaedt's profile image
06-11-2012 05:51 PM

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.


Comments

01-09-2018 04:35 PM

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!

01-03-2018 03:13 AM

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 ?

Regards

...............Michael

01-02-2018 01:44 PM

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

11-17-2017 07:55 AM

Hi Abhishek.

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 :

https://docops.ca.com/ca-service-management/17-0/en/reference/ca-service-desk-manager-reference-commands/technical-reference/rest-http-methods

even the wherclause based search is described there.

 

a good staring point for understandning how object whereclauses works, you can find here:

https://docops.ca.com/ca-service-management/17-0/en/building/building-ca-service-desk-manager/query-and-message-modifications/scoreboard-queries

 

Hope this helps

Kind regards

.............Michael

11-17-2017 05:32 AM

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.

 

Regards,

Abhishek

11-15-2017 05:46 AM

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.

11-15-2017 05:24 AM

Sorry didn't escaped the equal signs... :

.../caisd-rest/attmnt?WC=requests.cr.ref_num%3D'your incident number here'

and

.../caisd-rest/attmnt?WC=changes.chg.chg_ref_num%3D'your change number here'

....Michael

11-15-2017 05:21 AM

Hi Abhishek

  1.  yes I get Content-Disposition Header :Content-Disposition: attachment; filename="blabla.PNG" .
    Currently testing with soap-ui
  2. There are different approaches, normaly an attachment is related to an Incident or a Change order
    So if you know the Incident number (ref_num) you might want to do a GET to
    .../caisd-rest/attmnt?WC=requests.cr.ref_num='your incident number here'
    for changes it looks like
    .../caisd-rest/attmnt?WC=changes.chg.chg_ref_num='your change number here'
    this will give you a list of all ticket related attachment records.

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

...........Michael

11-15-2017 04:15 AM

Hi Michael,

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.

Regards,

Abhishek

11-15-2017 03:41 AM

Hi Abhishek

assuming 41234123 is a valid attachment record id, it worked for me (17.0) using :

http://sdm-host:8050/caisd-rest/attmnt/41234123/file-resource

and of course sending header X-AccessKey with a valid access key

Hope this helps

.........Michael

11-14-2017 08:07 AM

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?

 

Regards,

Abhishek

07-10-2017 09:51 AM

j.barger

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

Kind Regards

............Michael

07-07-2017 01:53 PM

@michael mueller,

The rest functionality allows you to create and delete attachments but not retrieve them.

06-29-2017 05:27 PM

I think it is delivered as part of the REST based webservice functionality.

06-28-2017 04:32 PM

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. 

11-17-2014 01:14 PM

Hi Russell,

 

 

Thank you.

I had tested with ServiceDesk, the method returned error, when I used another user the method worked fine.

 

 

Regards

11-16-2014 03:28 AM

I should have checked the case first Looks like we now have the test patch.

11-16-2014 03:23 AM

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.

11-15-2014 02:11 PM

Restful webservice SDM 12.9 + CP1 +test patch add thi
 s function. just have a look at the sample java pgm in the OotB sample folder

11-15-2014 08:18 AM

Userid is correct. First perform a login to get the sid and then getbopsid using that sid and the original userid.

 

 

11-15-2014 08:15 AM

Yes you should use userid to get bop_sid

 

Sent from my iPhone

11-15-2014 08:01 AM

Gutis,

 

Could you help me? I'm tried test the getBopsid method but in all tests I got a error message...

 

        <soapenv:Fault>

            <faultcode>soapenv:Client</faultcode>

            <faultstring/>

            <faultactor/>

            <detail>

                <ErrorMessage/>

                <ErrorCode>0</ErrorCode>

            </detail>

        </soapenv:Fault>

 

 

I used this call:

 

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">

    <Body>

        <getBopsid xmlns="http://www.ca.com/UnicenterServicePlus/ServiceDesk">

            <sid xmlns="">1300085181</sid>

            <contact xmlns="">fabricio.silva</contact>

        </getBopsid>

    </Body>

</Envelope>

 

 

 

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?

 

Thank you.

 

 

Fabricio

09-17-2014 05:47 AM

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.

09-16-2014 05:23 PM

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

09-10-2014 08:11 AM

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?