Thanks for the quick response mythz
I can get the fetch to work with a simplified example below where the Request.Files is populated, but I’d like to get the request DTO sent as well.
As far as I can tell I need to supply it in the POST url as Fetch doesn’t support parameters yet.
I was expecting client.createUrlFromDto to include the fileRequest.Path parameter is this not the case and should I be encoding it separately?
const client = new JsonServiceClient(environment.apiUrl);
const fileRequest = new UploadFiles();
uploadFile(environmentName: string, file : File): Promise<Response> {
fileRequest.Path = 'testPath';
var postUrl = client.createUrlFromDto('POST', fileRequest);
const formData = new FormData();
formData.append('description', file.name);
formData.append('type', 'file');
formData.append('file', file);
var result = fetch(postUrl,
{
method: 'POST',
headers: {
Accept: 'application/json'
},
body: formData,
});
return result;
}