loopback-api-testing icon indicating copy to clipboard operation
loopback-api-testing copied to clipboard

How to test a function which sends form-data in request?

Open tarunlnmiit opened this issue 5 years ago • 3 comments

tarunlnmiit avatar Oct 08 '19 12:10 tarunlnmiit

Assuming you mean a route which accepts a HTTP POST request, just put the form data in the withData field of the test.

jubbens avatar Oct 09 '19 15:10 jubbens

I have a request where I am uploading files using a multipart form-data. I tried putting the file path in the withData field. It showed me an error of "Unsupported file type 415", which is an error I am not throwing anywhere in the code.

tarunlnmiit avatar Oct 10 '19 08:10 tarunlnmiit

I assume it's because there is no Content-Type or Content-Encoding headers with the request. Currently an open issue if you want to add those to the package.

jubbens avatar Oct 10 '19 16:10 jubbens