Suppose we have the example RESTful app from Method 1 of this answer which takes string, float, boolean, and an arbitrary number of file inputs.
I cannot get Matlab's webwrite
to successfully post data to this API. It seems to only allow multiple form fields or data from a single file. Calling webwrite with a weboptions
argument is limited to a single key/value pair. I also tried argumenting the function call with multiple weboptions objects to provide each of the required fields, but that doesn't work either.
A workaround is to use a system call to curl
. This will work for the example app linked above:
system('curl -F name=foo -F point=0.13 -F is_accepted=false -F files=@test_files/a.txt -F files=@test_files/b.txt http://127.0.0.1:8000/submit');
Is there a more elegant way to accomplish this in Matlab?