problems with webread/weboptions
이전 댓글 표시
im trying to make a request to spotify with spotify api BUT when im filling the weboptions parameters and then execute the webread this is the result:
error: weboptions: HeaderFields must be of size m-by-2
error: called from
set.HeaderFields at line 311 column 11
webread at line 89 column 24
my code is here:
options=weboptions('HeaderFields',{'Accept' 'application/json';'Content-Type' 'application/json';'Authorization' 'Bearer BQCS1-3qa1vbElaF9wa2hoZacWQfULK_aH5QJt5bqAAYQ0oBBPXxjtbTg5X--DkI8cNdwdQ5dyP5ohpTDYAPMIkBmytfptLBUvRl4ZM14BIhO0By2DxcQvurUcaGjHSgEjfBOLQO2W9ok5aw0HEjZQ-HZh1IFvLFSamM-gqVFIeYYRsXQXk'})
then i execute the webread:
response=webread("https://api.spotify.com/v1/me",options)
the auth-token is copied exactly from the spotify website where i created the token
댓글 수: 4
Walter Roberson
2021년 5월 12일
I formatted your code and un-split the line... and the result works on my system.
Alexandros Loukas
2021년 5월 12일
Walter Roberson
2021년 5월 12일

Walter Roberson
2021년 5월 12일
The code you posted had
options=weboptions('HeaderFields',{'Accept' 'application/json';'Content-Type' 'application/json';'Authorization' 'Bearer BQCS1-3qa1vbElaF9wa2hoZacWQfULK_aH5QJt5bqAAYQ0oBBPXxjtbTg5X--
DkI8cNdwdQ5dyP5ohpTDYAPMIkBmytfptLBUvRl4ZM14BIhO0By2DxcQvurUcaGjHSgEjfBOLQO2W9ok5aw0HEjZQ-HZh1IFvLFSamM-gqVFIeYYRsXQXk'})
which was split across two lines and did not construct the strings properly. I removed the newline to join it together into one string
options=weboptions('HeaderFields',{'Accept' 'application/json';'Content-Type' 'application/json';'Authorization' 'Bearer BQCS1-3qa1vbElaF9wa2hoZacWQfULK_aH5QJt5bqAAYQ0oBBPXxjtbTg5X--DkI8cNdwdQ5dyP5ohpTDYAPMIkBmytfptLBUvRl4ZM14BIhO0By2DxcQvurUcaGjHSgEjfBOLQO2W9ok5aw0HEjZQ-HZh1IFvLFSamM-gqVFIeYYRsXQXk'})
under the assumption that the split was an artificat that did not exist in your actual code. The resulting line worked fine for me.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Web Services에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!