user1151816
user1151816

Reputation: 197

OTRS - Get article attachment through SOAP

I have no problem to access a ticket and its articles information through SOAP generic interface with php and java in a OTRS 3.2 server. But in the xml response I have no information about file attachments.

First, according to this API documentation (http://otrs.github.io/doc/api/otrs/3.2/Kernel/GenericInterface/Operation/Ticket/TicketGet.pm.html), I have used the TicketGet function with parameters DynamicFields, Extended, AllArticles and Attachments set to 1 to get the ticket, but I don't get any information about articles.

Next, according to this API (http://otrs.github.io/doc/api/otrs/3.2/Kernel/System/Ticket/Article.pm.html), I have used the function ArticleIndex to get the Id's ticket articles and then ArticleGet to get the article which has the attachment. I get the article information with message body but there's no attachments in the response.

There's something wrong in the functions calls? Maybe I'm missing some parameter. Or perhaps there's a bad OTRS configuration. In Admin->System config->Framework and Ticket options there's a lot of things to change.

Thanks

Upvotes: 1

Views: 4068

Answers (1)

Alexander Abakumov
Alexander Abakumov

Reputation: 14569

Just tested on OTRS Appliance 1.0.8 with OTRS Help Desk 3.3.8 and all is fine for me. I can get both articles and attachments using TicketGet method.

See the following article describing how to set up OTRS Web Service settings.

After OTRS Web Service setup is completed, I send the following SOAP request via SoapUI to the OTRS Ticket Connector endpoint (in my case http://192.168.112.34/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnector):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <TicketGet>
         <UserLogin>root@localhost</UserLogin>
         <Password>root</Password>
         <TicketID>965</TicketID>
         <AllArticles>1</AllArticles>
         <Attachments>1</Attachments>
    </TicketGet>
   </soapenv:Body>
</soapenv:Envelope>

And get the following in response:

<soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    <TicketGetResponse xmlns="http://www.otrs.org/TicketConnector/">
      <Ticket>
        <Age>160723</Age>
        <ArchiveFlag>n</ArchiveFlag>
        <Article>
          <ArticleID>3260</ArticleID>
          <ArticleType>webrequest</ArticleType>
          ...
          <Attachment>
            <Content>
              W0dlbmVyYWxdDQpTZXJ2ZXI9Mg0KQ3JlYXRlVGFibGU9MA0KW0Rlc3RdDQpTYXZlVG9GaWxlPTEN
              ...
              aXNoXQ0KTG9hZEludG9FZGl0b3I9MA0KQ2xvc2VBZnRlckNvbXBsaXRlPTANCg==
            </Content>
            <ContentAlternative/>
            <ContentID/>
            <ContentType>text/plain</ContentType>
            <Filename>1.smt</Filename>
            <Filesize>673 Bytes</Filesize>
            <FilesizeRaw>673</FilesizeRaw>
          </Attachment>
          <Attachment>
            <Content>
              REVDTEFSRSBAUkMgaW50DQpERUNMQVJFIEBMb2dnZWRVc2VySUQgaW50DQpERUNMQVJFIEBVc2Vy
              ...
              Y2hhbmdlc1htbA0KICAsQEJhc2VDb250cmFjdHNYbWwNCkdPDQoNCg==
            </Content>
            <ContentAlternative/>
            <ContentID/>
            <ContentType>application/octet-stream</ContentType>
            <Filename>3.sql</Filename>
            <Filesize>610 Bytes</Filesize>
            <FilesizeRaw>610</FilesizeRaw>
          </Attachment>
          <AttachmentIDOfHTMLBody>3</AttachmentIDOfHTMLBody>
          <Body>sdfghhfghg</Body>
        ...
        </Article>
      ...
      </Ticket>
    </TicketGetResponse>
  </soap:Body>
</soap:Envelope>

As you can see, I'm getting ticket's initial article with 2 attachments inside.

Hope this helps or do not hesitate to provide feedback on it.

Upvotes: 4

Related Questions