필터 지우기
필터 지우기

webread with comma in url

조회 수: 1 (최근 30일)
Khaled Khairy
Khaled Khairy 2016년 3월 24일
댓글: Guillaume 2016년 3월 24일
how can I use webread with comma in URL: e.g. my call: > url = 'page.html?q=1,2,3'; resp = webread(url);
Using webread this encodes to : page.html?q=1%2c2%2c3 and the server I'm calling returns an error (I have no control over that service and cannot change its API). There is much information about URI encoding, for example here: http://stackoverflow.com/questions/2366260/whats-valid-and-whats-not-in-a-uri-query But it doesn't help with Matlab's webread. Do you know what I need to do so that it passes a comma ","?

채택된 답변

Guillaume
Guillaume 2016년 3월 24일
That's because those things after the '?' are not really part of the URI, but are query parameters. webread separate these from the base URI. You just specify these query parameters after the base URI as pairs of parameter name and parameter value. In your example:
webread('http://somwhere.com/page.html', 'q', [1 2 3])
  댓글 수: 2
Khaled Khairy
Khaled Khairy 2016년 3월 24일
편집: Khaled Khairy 2016년 3월 24일
Thank you. This works for the above case. However, some APIs don't expect query parameters. I have an API call like this: >url = 'http://somewhere.com/somebranch/4,5';
is there a way for webread to construct this? (apologies if this seems to be a separate question) Again, the problem is the comma.
Guillaume
Guillaume 2016년 3월 24일
As far as I know, if your server makes a difference between
http://somewhere.com/somebranch/4,5
and
http://somewhere.com/somebranch/4%2c5
then your server is not http compliant. They are supposed to represent the exact same URI.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by