Search code examples
soapwsdlnetsuite

Netsuite get list of files inside a folder using soap webservice


I am actually trying to get a list of files(or their internalId's) inside a folder using soap webservice from netsuite file cabinet I am using the following request to make a search request

<soapenv:Header>
    <urn:tokenPassport>
        <urn1:account xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:account>
        <urn1:consumerKey xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:consumerKey>
        <urn1:token xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:token>
        <urn1:nonce xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:nonce>
        <urn1:timestamp xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:timestamp>
        <urn1:signature algorithm="HMAC-SHA256" xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:signature>
    </urn:tokenPassport>
</soapenv:Header>
<soapenv:Body>
    <search xmlns="urn:messages_2020_2.platform.webservices.netsuite.com">
        <searchRecord type="FileSearchBasic" xmlns="urn:common_2020_2.platform.webservices.netsuite.com">
            <folder type="SearchMultiSelectField" internalId="2760"/>
        </searchRecord>
    </search>
</soapenv:Body>

However its giving error following error

<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.xml.sax.SAXException: {urn:core_2020_2.platform.webservices.netsuite.com}SearchRecord is an abstract type and cannot be instantiated</faultstring>

Solution

  • after a lot of research I was able to make a successful soap request to get list of files inside a folder, following is the request body

    <soap:Body>
    <platformMsgs:search> 
        <platformMsgs:searchRecord xmlns:s0="urn:filecabinet_2020_2.documents.webservices.netsuite.com" xsi:type="s0:FolderSearchAdvanced"> 
            <s0:criteria> 
                <s0:basic> 
                    <internalId operator="anyOf"> 
                    <searchValue internalId="2760" type="folder" /> 
                    </internalId>
                </s0:basic>
            </s0:criteria> 
            <s0:columns>
                <s0:basic>
                    <internalId/>
                    <name/>
                </s0:basic>
                <fileJoin>
                    <internalId/>
                    <name/>
                    <modified/>
                    <documentSize/>
                </fileJoin>
            </s0:columns>
        </platformMsgs:searchRecord> 
    </platformMsgs:search>
    </soap:Body>