Upload file with webwrite including file and data parameter

3 ビュー (過去 30 日間)
Marcel Beining
Marcel Beining 2018 年 10 月 11 日
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 件)

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by