Reputation: 766
I'm uploading PDF file to node.js server with code below:
var file = new FileContentResult(...)
var client = new RestClient(_tenantOptions.BaseUrl + _tenantOptions.UploadPdfFilesUrn) {Timeout = _tenantOptions.RequestTimeoutMilliseconds};
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", accessToken);
request.AddFile("file", file.FileContents, file.ContentType);
var response = client.Execute<UploadFileResponse>(request);
This file appears on server like filename.undefined
though file.ContentType = "application/pdf"
. What did I miss?
Upvotes: 0
Views: 593
Reputation: 169338
According to the source code for RestSharp there's a 4-parameter form of AddFile
that accepts the filename too.
Try
request.AddFile("file", file.FileContents, "document.pdf", file.ContentType);
Upvotes: 1