Hi there
I am trying to make a request to a Dancer application which is initialized as I indicate:
# perl serv.pl
>> Dancer 1.3513 server 9802 listening on http://xxx.xx.xx.xx:xx
>> Dancer::Plugin::REST (0.11)
== Entering the development dance floor ...

But when I tried to execute below command
curl http://ipaddress:port/reference/C00-1412-0010

It shows this result:
curl http://ipaddress:port/reference/C00-1412-0010

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Error 500</title> <link rel="stylesheet" href="/css/style.css" /> <meta http-equiv="Content-type" content="text/html; charset=UTF-8" /> </head> <body> <h1>Error 500</h1> <div id="content"> <h2>Unable to process your query</h2>The page you requested is not ava +ilable </div> <div id="footer"> Powered by <a href="http://perldancer.org/">Dancer</a> 1.3513 </div> </body> </html>#

This is part of the code
package MyWebService; use strict; use warnings; use Dancer; use Dancer::Plugin::REST; use Config::File::Simple; use File::Slurp; use URI::Encode qw(uri_encode uri_decode); use IO::Socket; use IO::Select; use Storable; use Tie::IxHash; use REST::Client; use MIME::Base64; set server => 'xxx.xx.xx.xx'; get '/reference/:reference' => sub { writeLog("Arrived reference: " . params->{reference}); my (@arrRes, @arrNoRes) = processRequest(params->{reference}); if (@arrNoRes > 0) { push(@arrRes, @arrNoRes); } my $jsonResponse; if (@arrRes == 0) { $jsonResponse = to_json { reference => params->{reference} } +; } else { writeLog("Found results: " . Dumper(\@arrRes)); $jsonResponse = encode_json(\@arrRes); } return $jsonResponse; }; dance; . . .
Below are all the functions called for this code.
What is missing to allow this code works when it is invoked as a url with curl command?


In reply to I cannot execute a url request through Dancer by logangha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.