Upload file with webwrite including file and data parameter
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Web Services 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!