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 Comments

I formatted your code and un-split the line... and the result works on my system.
can you send me a screenshot? i dont get what do you mean by "un-split the line".
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.

Sign in to comment.

Answers (0)

Asked:

on 12 May 2021

Commented:

on 12 May 2021

Community Treasure Hunt

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

Start Hunting!