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
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 日
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