Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Muzhi Ou](https://secure.gravatar.com/avatar/f265f6d3bba8227e1cb30970cc7a42fa?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Muzhi Ou
4,921 PointsPOST ERROR: The requested route [/sign-in] has not been mapped in Spark
I tried to run the same code in Accepting request video on my computer, but spark keeps saying: The requested route [/sign-in] has not been mapped in Spark, and a 404 Not Found page keeps being returned
Can someone please help me with this? I really don't know where the problem is
Thanks!
![Muzhi Ou](https://secure.gravatar.com/avatar/f265f6d3bba8227e1cb30970cc7a42fa?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Muzhi Ou
4,921 PointsMy code is:
public class Main {
public static void main(String[] args){
get("/hello", (req, res) -> "Hello World");
post("/sign-in", (req, res) -> {
return new ModelAndView(
new HashMap<String,String>().
put("name",req.queryParams("username")),
"sign-in.hbs"
);
},new HandlebarsTemplateEngine());
}
}
Stuff in sign-in.hbs is the same as the one in the video. I was actually trying to make post request through query string so it was something like: localhost:4567/sign-in?username=sth
2 Answers
![Seth Kroger](https://secure.gravatar.com/avatar/b5bdc43c1e576145fb404edba6fea5a6?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Seth Kroger
56,413 PointsYou can't make a POST request with the query parameters as part of the URL. That's a GET request. POSTs send the query paramenters in the body of the request instead. If you want to make a POST, you need to submit the sign-in form in index or use a tool like Postman to submit the request.
![Muzhi Ou](https://secure.gravatar.com/avatar/f265f6d3bba8227e1cb30970cc7a42fa?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Muzhi Ou
4,921 PointsThanks! I just tried using get method in spark and it worked! I still have three questions though: if http get request can also send query parameters like post request, then what is the difference between the two? Isn't that get method can do everything that post can do except that post method has to be sent through some special programs? (And maybe easier to do?)
I did tried to use telnet (without using query string) to send a post request but I still get the same results back. Why?
Also, is it because when I send localhost:4567/sign-in?username=sth to spark server, server actually receive a message saying that this is a get method, and hence it says this route is not "mapped by spark"?
Thanks very much!!
![Seth Kroger](https://secure.gravatar.com/avatar/b5bdc43c1e576145fb404edba6fea5a6?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Seth Kroger
56,413 PointsPOST and GET have different uses. GET is used for retrieving data, so a query string attached to it is related to the data you want to find. POST is used for sending data to the server (like username and password). In the REST standard, POST is specifically for creating a new resource (like creating a new login session).
/sign-in?username=foo doesn't work because it's not /sign-in. There are ways to specify the route will accept paramenters in the path Craig will get to later in the course.
![Muzhi Ou](https://secure.gravatar.com/avatar/f265f6d3bba8227e1cb30970cc7a42fa?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Muzhi Ou
4,921 PointsI see! Thanks!
Seth Kroger
56,413 PointsSeth Kroger
56,413 PointsYour code?