matlab URI can not access to a valid url webpage

3 views (last 30 days)
Shan Su
Shan Su on 1 Jul 2020
Answered: Rik on 1 Jul 2020
Hi,
I tried to use URI to request and receive response from internet. However, it says "invalid url", while I'm pretty sure the url is correct (since I can access with web browser). I was thinking that the '|' character raised the problem.
Here is my url (I delete my key here):
Here is how I use the function.
r = RequestMessage;
uri = URI(http://maps.googleapis.com/maps/api/staticmap?center=Chicago&zoom=19&size=800x800&style=color:0x000000&style=feature:road|element:geometry|color:0xffffff&style=element:labels|visibility:off&key=XXXXXXXX);
resp = send(r,uri);
I also tried to replace '|' with '%7C', but URI cropped the string after '%'.
Thank you in advance,

Answers (1)

Rik
Rik on 1 Jul 2020
You forgot to input the URI as a char array:
r = RequestMessage;
uri = URI('http://maps.googleapis.com/maps/api/staticmap?center=Chicago&zoom=19&size=800x800&style=color:0x000000&style=feature:road|element:geometry|color:0xffffff&style=element:labels|visibility:off&key=XXXXXXXX');
resp = send(r,uri);

Categories

Find more on Downloads in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!