Upload file with webwrite including file and data parameter
3 views (last 30 days)
Show older comments
Hi, I try to send a HTTPS Post request using webwrite but it seems I cannot provide all the necessary data as I get a "Bad Request" response. In Python the request works and is as simple as
uri = 'https://........'
response = requests.post(uri,
headers = {'X-Auth-Token': SOMETOKEN},
files = {'file1': FILEREADED},
data = {'createGroupForEachFile': 'false'})
In Matlab (2015 and 2017) I tried many different combinations of giving this data to webwrite and weboptions, but I always get the "bad request" response. What am I doing wrong? Is it possible to give "files" and "data" at the same time with Matlab webwrite? Here some example code (with which I get the bad request). I also tried around with weboptions and MediaType option without success:
url = 'https://......';
opt = weboptions;
opt.RequestMethod = 'post';
opt.HeaderFields = {'X-Auth-Token', SOMETOKEN};
response = webwrite(url,'files',{'file1',FILEREADED},'data',{'createGroupForEachFile': 'false'},opt);
0 Comments
Answers (0)
See Also
Categories
Find more on Web Services in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!