How to implement an API REST POST in Matlab

41 ビュー (過去 30 日間)
Vitor Bedotti
Vitor Bedotti 2021 年 8 月 27 日
回答済み: Sean de Wolski 2021 年 8 月 27 日
I was able to implement a API GET using webread as following
api = 'https://api.pontomais.com.br/external_api/v1/teams?attributes=id,code,name,department,leader';
options = weboptions('KeyName','access-token','KeyValue','XXXXXX');
Data = webread(api,options);
However I dont know how to implement a POST in Matlab. See next the POST in cURL. Does anyone know how to do it?
curl --location --request POST 'https://api.pontomais.com.br/external_api/v1/reports/work_days' \
--header 'Content-Type: application/json' \
--header 'access-token: XXXXXX' \
--data-raw '{
"report": {
"start_date": "2021-06-01",
"end_date": "2021-07-01",
"group_by": "employee",
"row_filters": "with_inactives,has_time_cards",
"columns": "date,shift_name,time_breaks,shift_appointments,time_cards,summary,extra_time,total_time,shift_time,custom_interval_time,overnight_time,registration_number,time_balance,motive, employee_id",
"format": "json"
}
}'
  1 件のコメント
TADA
TADA 2021 年 8 月 27 日
編集済み: TADA 2021 年 8 月 27 日

サインインしてコメントする。

採用された回答

Sean de Wolski
Sean de Wolski 2021 年 8 月 27 日
Look at either:
weboptions('RequestMethod','post')
ans =
weboptions with properties: CharacterEncoding: 'auto' UserAgent: 'MATLAB 9.10.0.1716447 (R2021a) Update 4' Timeout: 5 Username: '' Password: '' KeyName: '' KeyValue: '' ContentType: 'auto' ContentReader: [] MediaType: 'auto' RequestMethod: 'post' ArrayFormat: 'csv' HeaderFields: [] CertificateFilename: 'default'
or
doc webwrite

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeJSON Format についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by