Monday, April 22, 2019

Getting Case Attachments from Messages via Web Services

Users cannot directly access the attachments when the case records are fetched via Web Services. Please see below for sample SOAP requests on how to get the file attachments from a case via Web Services:
1) 'search' for messages associated to case:
      <platformMsgs:search
          xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com"
          xmlns:platformMsgs="urn:messages_2013_1.platform.webservices.netsuite.com"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:platformCommon="urn:common_2013_1.platform.webservices.netsuite.com"
          xmlns:s0="urn:communication_2013_1.general.webservices.netsuite.com"
         <platformMsgs:searchRecord xsi:type="s0:MessageSearch">
            <s0:caseJoin>
               <platformCommon:internalId operator="anyOf">
                  <platformCore:searchValue internalId="42" />
               </platformCommon:internalId>
            </s0:caseJoin>
         </platformMsgs:searchRecord>
      </platformMsgs:search>
2) 'get' message using internal ID from the response of step 1:
      <platformMsgs:get
          xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com"
          xmlns:platformMsgs="urn:messages_2013_1.platform.webservices.netsuite.com"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <platformMsgs:baseRef xsi:type="platformCore:RecordRef" internalId="3847" type="file" />
      </platformMsgs:get>
*SOAP response from step 2 will contain 'mediaItemList' as the list of files attached
3) 'search' for file using filename (and potentially folder name) from step 2.
      <platformMsgs:search
          xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com"
          xmlns:platformMsgs="urn:messages_2013_1.platform.webservices.netsuite.com"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:platformCommon="urn:common_2013_1.platform.webservices.netsuite.com"
          xmlns:s0="urn:filecabinet_2013_1.documents.webservices.netsuite.com"
         <platformMsgs:searchRecord xsi:type="s0:FileSearch">
            <s0:basic>
               <platformCommon:name operator="is">
                  <platformCore:searchValue>00000001.txt</platformCore:searchValue>
               </platformCommon:name>
            </s0:basic>
         </platformMsgs:searchRecord>
      </platformMsgs:search>
4) 'get' file using internal ID from the response of step 3:
      <platformMsgs:get
          xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com"
          xmlns:platformMsgs="urn:messages_2013_1.platform.webservices.netsuite.com"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <platformMsgs:baseRef xsi:type="platformCore:RecordRef" internalId="3847" type="file" />
      </platformMsgs:get>
*SOAP response from step 3 will contain the 'content' field as the base64 encoded contents of the file

No comments:

Post a Comment