Dom156
Dom156

Reputation: 11

Download file from NetSuite File Cabinet using API

I'm trying to create a solution where I run SuiteScript with a Saved Search and export the results as CSV into File Cabinet. I've got a rough Script and a Search but I haven't found a way to download files via the default API.

I've gone through the NetSuite pdf's about web services and rest/soap api but the only reference to File Cabinet was webservices (https://docs.oracle.com/cloud/latest/netsuitecs_gs/NSTWP/NSTWP.pdf). I also don't know how to use the schema browser (https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2020_1/script/record/salesorder.html)

Can I download a NetSuite file using a default API i.e. SOAP/Rest? What would I need to call the API? What would a URL look like? Is it worth creating a new integration on NetSuite?

(My end goal is: SuiteScript + Search > CSV > Download file via API > Upload to Azure Blob)

Upvotes: 1

Views: 5024

Answers (1)

Jay
Jay

Reputation: 41

Use SOAP webservice "get" call to retrive the file from Netsuite and then export to Azure. Below is the sample xml using file internal id, if id is not known, search on a particular folder via webservices to get all file ids and then make a get call to Netsuite

<soapenv:Envelope
    xmlns:xsd='http://www.w3.org/2001/XMLSchema'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
    xmlns:platformCore='urn:core_2020_1.platform.webservices.netsuite.com'
    xmlns:platformMsgs='urn:messages_2020_1.platform.webservices.netsuite.com'>
    <soapenv:Header>
        <passport xsi:type='platformCore:Passport'>
            <email xsi:type='xsd:string'>p@***</email>
            <password xsi:type='xsd:string'>*********</password>
            <account xsi:type='xsd:string'>*****</account>
            <role xsi:type='platformCore:RecordRef' internalId='3'/>
        </passport>
        <applicationInfo xsi:type='platformMsgs:ApplicationInfo'>
            <applicationId xsi:type='xsd:string'>7*****</applicationId>
        </applicationInfo>
    </soapenv:Header>
    <soapenv:Body>
        <get xsi:type='platformMsgs:GetRequest'>
            <baseRef xsi:type='platformCore:RecordRef' internalId='5902' type='file'/>
        </get>
    </soapenv:Body>
</soapenv:Envelope>

Upvotes: 3

Related Questions