Getting error when upload training data for Azure Custom Translator using API with C#

24 Views Asked by At

When I run the CustomTranslatorApiSamples solution in Visual Studio to upload combofile, I get the following error but I have successfully created workspace, project with the sample code.

https://github.com/MicrosoftTranslator/CustomTranslatorApiSamples

enter image description here

Here is my code - uploading an Excel file as ComboFile. Debugging “result” returns “Response status code does not indicate success:400 (Bad Request)."

enter image description here

Also, can you elaborate what the structure of “Files” and “DocumentDetails” in the Request Body should be.

enter image description here

1

There are 1 best solutions below

0
kiamehr hosseini On

For the exception error I think your file is not a valid JSON, check the file content.

You should use [FromForm] attribute and IFormFile in your API method parameter. See this:

public async Task<IActionResult> UploadFile([FromForm] FileUploadRequest request)


public class FileUploadRequest
{
    public IFormFile File { get; set; }
}

Or

public async Task<IActionResult> UploadFile([FromForm] IFormFile file)

Then you can upload the desired file in swagger.