admin管理员组

文章数量:1123106

I have a restful API post function build in C# on the ASP.NET framework that expects a request body object with one major parameter being of type byte[]. The service is designed to take a file's byte array, and process it.

I am testing it using postman. Because it requires a byte[] providing it through postman seems very cumbersome. I need to get the byte array, then convert that byte array to a numeric array and pass that whole string into the raw JSON object.

In my small test file this is a 9000 record integer array. I assume it gets worse the bigger the file gets. In addition, getting this array as string required setting up a debug session and writing some code to get the int array string out. It doesn't feel right or efficient.

I attempted to solve this by executing the post call with form-data (multipart/form-data) so I could have a field of type file, as well as fields for the other values, but this also presented problems, namely, the service couldn't execute with multipart/form-data. I have many services that pass in byte[] so I know it works, but is there any alternatives that make the process easier to test?

本文标签: cAlternative to using byte in restful API function to ease testing using postmanStack Overflow