Hi, anyone managed to upload a json from Netsuite ...
# suitescript
j
Hi, anyone managed to upload a json from Netsuite to an AWS presigned url? I keep getting the Status: 403, Response: ?xml version="1.0" encoding="UTF-8"? ErrorCodeSignatureDoesNotMatch/CodeMessageThe request signature we calculated does not match the signature you provided. what The error mostly occurs when Content-type is incorrect. I have tried to do the following: • Leave Content-Type empty -> Suitescript error • Leave Headers empty -> Suitescript makes it text/xml • Set Content-Type to application/octet-stream -> not accepted by AWS • Set Content-Type to text/plain -> not accepted by AWS Looks like Suitescript does not allow you to not set Content-type
Copy code
function uploadToPresignedUrl(presignedUrl, jsonContent) {
        try {

            var headers = {'Content-Type': 'application/octet-stream'};

            var response = https.put({
                url: presignedUrl,
                body: jsonContent,
                headers: headers
            });
            
            if (response.code === 200) {
                log.debug({
                    title: 'Upload Response',
                    details: response.body
                });

                log.debug({
                    title: 'Upload successful',
                    details: 'File uploaded to presigned URL'
                });
                return true;
            } else {
                log.error({
                    title: 'Upload failed',
                    details: 'Status: ' + response.code + ', Response: ' + response.body
                });
                return false;
            }
        } catch (e) {
            log.error({
                title: 'Error in uploadToPresignedUrl function',
                details: e
            });
            return false;
        }
    }
anyone?
u
did you try ‘Content-Type’: ‘application/json’,
j
Yes, but any content type is not accepted. So still no solution within suitescript. I build a specific lambda as middleware that forwards the request to the AWS presigned url