can you setup a RESTlet Post to accept a file from...
# suitescript
r
can you setup a RESTlet Post to accept a file from an external rest service
b
depends on how much control the external service has over its request
restlets generally require some form of plain text
r
yes, this is .csv, that I have decrypted and now is a plain text csv file
I am doing the posting well
b
then you only really need to post the contents of the csv file to the restlet
and set the appropriate content type header
r
from the c# rest service, I can upload a post json body request, now modifying the request to be a file in the request as such:
b
you can also use json if you want, you just put the contents of the csv in a key on the json object
r
using the ResSharp RestRequest
sure, I could extract the csv data post, then create a file inside of NetSuite from the restlet, but it would be nice to just send the whole file
request.AddHeader("cache-control", "no-cache"); request.AddHeader("authorization", authorization); request.AddHeader("Content-Type", "text/csv"); var fileName = Path.GetFileName(filePath); // add file to the request object request.AddFile("file", File.ReadAllBytes(filePath), fileName); request.RequestFormat = DataFormat.Json; // TODO MAY NOT NEED
b
go read the documentation on content types
the one you are trying to set is invalid
r
the request looks good, but does not even get into the restlet
ok