Upload file with webwrite including file and data parameter

조회 수: 5 (최근 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 CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by