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
Walter Roberson 2021년 5월 12일
I formatted your code and un-split the line... and the result works on my system.
Alexandros Loukas
Alexandros Loukas 2021년 5월 12일
can you send me a screenshot? i dont get what do you mean by "un-split the line".
Walter Roberson
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개)

질문:

2021년 5월 12일

댓글:

2021년 5월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by