CA Service Management

 View Only
Expand all | Collapse all

Web Service - How do I use addComment() and createAttachment()?

  • 1.  Web Service - How do I use addComment() and createAttachment()?

    Posted Apr 19, 2018 11:11 AM

    Hello everybody, I'm having some problems using addComment and createAttachment methods, can someone explain me how to it?

     

    using the addComment method I have this:

     

    <sid>1717813834</sid>
    <comment>'Esto es un comentario insertado desde WebService'</comment>
    <docId>905076</docId>
    <email></email>
    <username></username>
    <contactId>5E54CE3FF09EBD4883A324F8A5EC552C</contactId>
    </ser:addComment>

     

    and it response me:

    <soapenv:Fault>
    <faultcode>soapenv:Client</faultcode>
    <faultstring>Error - invalid document id</faultstring>
    <faultactor/>
    <detail>
    <ErrorMessage>Error - invalid document id</ErrorMessage>
    <ErrorCode>1000</ErrorCode>
    </detail>
    </soapenv:Fault>

     

    and the createAttachment method I don't know how can I use it.

     

    Forward thanks!!!



  • 2.  Re: Web Service - How do I use addComment() and createAttachment()?

    Broadcom Employee
    Posted Apr 19, 2018 11:29 AM

    Carlos, I would start by change

    'Esto es un comentario insertado desde WebService'

    to

    Esto es un comentario insertado desde WebService

    And double check if 905076 is a valid doc id(for example, from web interface, use "search by document id" and enter this id and see if there is such doc). Thanks _Chi



  • 3.  Re: Web Service - How do I use addComment() and createAttachment()?

    Posted Apr 19, 2018 11:41 AM

    Thanks for the help Chi, I used the doSelect method to search the id for that ticket, Is that the same ID? or there are other way to know it, using the doSelect method?

    Thanks Chi!



  • 4.  Re: Web Service - How do I use addComment() and createAttachment()?

    Broadcom Employee
    Posted Apr 19, 2018 11:53 AM

    Carlos, addComment() is a method for knowledge documents and that id(docId) is the document id for certain document. It is not id of a ticket. To search for documents you can use doSelectKD() and and specify the id in the return attributes(attributes). Please refer to

    Web Services Knowledge Management - CA Service Management - 17.1 - CA Technologies Documentation 

    for more details. Thanks _Chi



  • 5.  Re: Web Service - How do I use addComment() and createAttachment()?

    Posted Apr 19, 2018 12:56 PM

    Chi, Do you know somehow to add a comment to a ticket? There is some method to do that?



  • 6.  Re: Web Service - How do I use addComment() and createAttachment()?

    Posted Apr 19, 2018 01:45 PM

    You would use create activity log and the logType would be LOG. That would create the equivalent of a Log Comment in the Web UI.



  • 7.  Re: Web Service - How do I use addComment() and createAttachment()?

    Broadcom Employee
    Posted Apr 19, 2018 01:52 PM

    Carlos, yes you could use logComment() to log a comment for a ticket:

    logComment(int sid, String ticketHandle, String comment, int internalFlag)

    Thanks _Chi



  • 8.  Re: Web Service - How do I use addComment() and createAttachment()?

    Posted Apr 19, 2018 02:17 PM

    Thanks Chi!!! It works perfectly!!! 

    Do you know how to attach a file to a ticket? I think I need to use the createAttachment method: at this moment I have this to do that:

     

    <ser:createAttachment>
    <sid>1890344182</sid>
    <repositoryHandle></repositoryHandle>
    <objectHandle>cr</objectHandle>
    <description>Subido desde webservice</description>
    <fileName>C:\Users\cescobedo\Downloads\amCharts.jpg</fileName>
    </ser:createAttachment>

     

    But it returns me this:

    <detail>
    <ErrorMessage>Internal err with get_object_values: NOT FOUND</ErrorMessage>
    <ErrorCode>102</ErrorCode>
    </detail>

     

    Do you know how can I attach a file?



  • 9.  Re: Web Service - How do I use addComment() and createAttachment()?

    Broadcom Employee
    Posted Apr 19, 2018 02:27 PM

    Carlos, please look at an example here

    Web Services Attachment-Related Methods - CA Service Management - 17.1 - CA Technologies Documentation 

    and this is an java example:

    FileDataSource fds = new FileDataSource(filename); DataHandler dhandler = new DataHandler(fds); CASDM._setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME); CASDM.addAttachment(dhandler);  String handle = CASDM.createAttachment(sid, repHandle, objHandle, description, filename);

    Thanks _Chi



  • 10.  Re: Web Service - How do I use addComment() and createAttachment()?

    Posted Apr 19, 2018 02:35 PM

    Chi how can I know the repositoryHandle? 

    which value will be that or how can I get it?

    Can you guide me?



  • 11.  Re: Web Service - How do I use addComment() and createAttachment()?

    Broadcom Employee
    Posted Apr 19, 2018 02:47 PM

    Carlos, the repHandle is the attachment repository handle. Usually it is the handle for Service Desk repository so it is static and you can hard code it as "doc_rep:xxxxx". For example, running

    pdm_extract -f "select persid from Document_Repository where sym='Service Desk'"
    TABLE Document_Repository
            persid
            { "doc_rep:1002" }
    Document_Repository
            rows:1

     

    shows you can hard code it as "doc_rep:1002". Thanks _Chi



  • 12.  Re: Web Service - How do I use addComment() and createAttachment()?

    Posted Apr 19, 2018 02:59 PM

    Thanks Chi for the Help you are amezing!

    Trying to uploading the file, I have this error:

    <faultstring>Error - could not perform the operation, policy limit exceeded</faultstring>

    how can I fix it? 

    I'm using this method:

    <ser:createAttachment>
    <sid>1890344182</sid>
    <repositoryHandle>doc_rep:1002</repositoryHandle>
    <objectHandle>cr:905076</objectHandle>
    <description>Subido desde webservice</description>
    <fileName>C:\Users\cescobedo\Downloads\amCharts.jpg</fileName>
    </ser:createAttachment>



  • 13.  Re: Web Service - How do I use addComment() and createAttachment()?

    Broadcom Employee
    Posted Apr 19, 2018 03:08 PM

    Carlos, I think you missed the first part as shown in the java example

    FileDataSource fds = new FileDataSource(filename); DataHandler dhandler = new DataHandler(fds); CASDM._setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME); CASDM.addAttachment(dhandler);

    It seems you use soap ui( for testing purpose?). I am not sure how you do that part in soap ui. However, if you try this for testing purpose, I recommend using the sample java code for that. You can easily find the sample java code in the samples\...folder. Thanks _Chi



  • 14.  Re: Web Service - How do I use addComment() and createAttachment()?
    Best Answer

    Broadcom Employee
    Posted Apr 19, 2018 03:29 PM

    Carlos, I googled and found this

    SOAP Attachments and Files | SoapUI 

    I didn't try this yet but just throw it here for you. Pay attention to the this part "SWA (SOAP with Attachments, also known as MIME for Web Services) – A MIME-based attachment mechanism for SOAP/HTTP. SoapUI supports plain SWA as well as swaRef attachments in accordance with the WS-I Attachments Profile". Thanks _Chi



  • 15.  Re: Web Service - How do I use addComment() and createAttachment()?

    Posted Apr 19, 2018 04:31 PM

    It works perfectly Chi, you are awesome! Thanks dude!!!



  • 16.  Re: Web Service - How do I use addComment() and createAttachment()?

    Broadcom Employee
    Posted Apr 19, 2018 04:35 PM

    Carlos, glad to know that things worked out good for you. Thanks _Chi