I am trying to test response after uploading 3 .csv files, as part of integration tests for API on project I am currently on.
public void UploadFile(string token)
{
request = new RestRequest(Method.POST);
endpoint.Timeout = -1;
request.AlwaysMultipartFormData = true;
request.AddHeader("Authorization", $"Bearer {token}");
request.AddHeader("Content-Type", "multipart/form-data");
request.AddFile("Customers", "Users/Dell/Downloads/ProRecoFiles/CUSTOMERS.csv");
//request.AddFile(Constants.customers, Constants.customersPath);
//request.AddFile(Constants.orders, Constants.ordersPath);
//request.AddFile(Constants.products, Constants.productsPath);
endpoint.Execute(request);
}
Although I'm relatively new to Restsharp and C#, I would say this is pretty straight forward request. But apparently something is wrong as I get:
Message:
System.IO.FileNotFoundException : Could not find file 'C:\Users\Dell\Source\Repos\proreco-client-api\ProReco.Client.API\Tests\bin\Debug\netcoreapp3.1\Users\Dell\Downloads\ProRecoFiles\CUSTOMERS.csv'.
In the request.AddFile() I am passing name of file and path to the file. Somehow it concatenate value of file path to location of my project. Any idea how to fix that? Any suggestion would be great.
Aucun commentaire:
Enregistrer un commentaire