필터 지우기
필터 지우기

HTTP POST request API

조회 수: 58 (최근 30일)
Orkhan Alikhanov
Orkhan Alikhanov 2021년 8월 6일
댓글: Orkhan Alikhanov 2021년 8월 13일
I am trying to send a POST request to Notion with json body. The request contains a header with three fields.
I get an response HTTP/1.1 400 Bad Request. What am I doing wrong? Everything works through Postman. I also tried to shape the request body as a matlab structure.
My code:
data = '{"parent":{"database_id":"<my_id>"},"properties":{"title":{"title":[{"text":{"content":"hello"}}]}}}';
uri=matlab.net.URI('https://api.notion.com/v1/pages');
method = matlab.net.http.RequestMethod.POST;
header = matlab.net.http.HeaderField('Authorization', 'Bearer <secret_token>',...
'Content-Type', 'application/json',...
'Notion-Version','2021-05-13');
body = matlab.net.http.MessageBody(data);
request = matlab.net.http.RequestMessage(method,header,body);
[response,completedrequest,history] = send(request,uri)
  댓글 수: 4
Reeshabh Ranjan
Reeshabh Ranjan 2021년 8월 13일
@Orkhan Alikhanov its working now, right?
Orkhan Alikhanov
Orkhan Alikhanov 2021년 8월 13일
@Reeshabh Ranjan Yes. Thank you!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Web Services from MATLAB Using HTTP에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by