http request problem
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 58
- Joined: Sat Jun 15, 2019 10:09 am
http request problem
Hi There
I've just come back to livecode after a while and something I'd already done doesn't seem to work?
I've formed htto requests before without any problems, but now this happens:-
GET url ("https://www.googleapis.com/youtube/v3/s ... t&q=little simz, offence&key=AIzaSyC-k5IU6jr9eHxL7Zkt-QQEO4pPW4zdIp0") ; put it into theURL
-works fine, but if I try to add in variables
put "https://www.googleapis.com/youtube/v3/s ... snippet&q=" & ttitle & ", " & tartist & "&key=AIzaSyDUT_zKdAsDjXNmUzyiGQU-9ooAewZ3qQE" into theURL
GET url(theURL) ; put it into theURL
-it doesn't work. could anyone suggest why?
kind regards
Paul
I've just come back to livecode after a while and something I'd already done doesn't seem to work?
I've formed htto requests before without any problems, but now this happens:-
GET url ("https://www.googleapis.com/youtube/v3/s ... t&q=little simz, offence&key=AIzaSyC-k5IU6jr9eHxL7Zkt-QQEO4pPW4zdIp0") ; put it into theURL
-works fine, but if I try to add in variables
put "https://www.googleapis.com/youtube/v3/s ... snippet&q=" & ttitle & ", " & tartist & "&key=AIzaSyDUT_zKdAsDjXNmUzyiGQU-9ooAewZ3qQE" into theURL
GET url(theURL) ; put it into theURL
-it doesn't work. could anyone suggest why?
kind regards
Paul
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: http request problem
1. Have you verified that ttitle and tartist contain what you expect? Does the resulting URL work in a browser?
2. Is that your actual app API key? If so you might want to change it now that it's been posted in a public forum.
2. Is that your actual app API key? If so you might want to change it now that it's been posted in a public forum.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: http request problem
& ttitle & ", "& tartist & "&key=AIzaSyDUT_zKdAsDjXNmUzyiGQU-9ooAewZ3qQE" into theURL
Watch out....
A space in a URL is a no go....
And it's clear to me that you have a space in your URL
(after the comma)
Watch out....
A space in a URL is a no go....
And it's clear to me that you have a space in your URL
(after the comma)
-
- Posts: 58
- Joined: Sat Jun 15, 2019 10:09 am
Re: http request problem
Hi There
I have tested the resulting URL in the browser and it works fine (it returns the json response as expected), so the variables and the key work.
if I 'put' the result with the variable URL, I get this back????
Kind regards
Paul
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 400 (Bad Request)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelo ... 0x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelo ... 0x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelo ... 0x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelo ... 0x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>400.</b> <ins>Thatâs an error.</ins>
<p>Your client has issued a malformed or illegal request. <ins>Thatâs all we know.</ins>
I have tested the resulting URL in the browser and it works fine (it returns the json response as expected), so the variables and the key work.
if I 'put' the result with the variable URL, I get this back????
Kind regards
Paul
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 400 (Bad Request)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelo ... 0x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelo ... 0x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelo ... 0x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelo ... 0x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>400.</b> <ins>Thatâs an error.</ins>
<p>Your client has issued a malformed or illegal request. <ins>Thatâs all we know.</ins>
Re: http request problem
When you test the URL in a browser, the browser itself inserts a %20 to replace the 'space' in the address, where as Lc does not, you'd have to insert those yourself through code if such are there, hence what bangkok is telling you.bangkok wrote: ↑Sun Mar 01, 2020 6:56 amA space in a URL is a no go....paulalsmith1000 wrote: ↑Sun Mar 01, 2020 11:45 amI have tested the resulting URL in the browser and it works fine
-
- Posts: 58
- Joined: Sat Jun 15, 2019 10:09 am
Re: http request problem
Thank you very much for your help.
It turns out I was being a div anyway!
I'd removed the space before, because I thought it might be the problem, but it had no affect.
It's only the last post that made me look back through it (I thought if it worked in the browser, it would work in LC).
stupidly the error is in one of the variables - there is a space between the first and second name of the artist!!!!!!
so I put the 2 together and used urlencode, al good.
thanks v much again
Paul
It turns out I was being a div anyway!
I'd removed the space before, because I thought it might be the problem, but it had no affect.
It's only the last post that made me look back through it (I thought if it worked in the browser, it would work in LC).
stupidly the error is in one of the variables - there is a space between the first and second name of the artist!!!!!!
so I put the 2 together and used urlencode, al good.
thanks v much again
Paul