Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

I got HTTP POST error message: Internal Server Error

by iamAnne (Initiate)
on Sep 19, 2014 at 03:34 UTC ( #1101140=perlquestion: print w/replies, xml ) Need Help??

iamAnne has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I had a problem when I run my perl script it displays error in HTTP Post error code 500 and error message : Internal Server Error. Please advise how will I handle this. Thank you in advance.

My script

use warnings; use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $url = "https://host/WebService/webservice.php"; # set custom HTTP request header fields my $req = HTTP::Request->new(POST => $url); $req->header('content-type' => 'application/json'); $req->header('x-auth-token' => 'kfksj48sdfj4jd9d'); # add POST data to HTTP request body my $post_data = '{"List": {"Data" : [ {"value" : "SRYSR656", "value2" +: "STYDTY ","date" : "140810","time" : "2132" },{ "value" : "001695 +568GP,"value2" : "EEFGE54","date" : "140812","time" : "1205"},{ "val +ue" : "YYHG","value2" :"JKTYRT6F","date" : "140811","time" : "1302" } +, {"value" : "ERETUT","value2" : "DYTUYU","date":"140812","time" : "1 +102" },{"value" : "SRT4543","value2" : "DASDRGF","date" : "140811","t +ime" : "2245"} ] }}'; $req->content($post_data); print $req->as_string; my $resp = $ua->request($req); if ($resp->is_success) { my $message = $resp->decoded_content; print "Received reply: $message\n"; } else { print "HTTP POST error code: ", $resp->code, "\n"; print "HTTP POST error message: ", $resp->message, "\n"; }

Replies are listed 'Best First'.
Re: I got HTTP POST error message: Internal Server Error
by Gangabass (Vicar) on Sep 19, 2014 at 04:58 UTC
    Try to make same request in your browser, record it (using Firefox's Firebug or HTTPFox or Wireshark). Next analyze it and compare to your request from the program, make changes and be happy.

      I'm already did but still I get the same error?

        The error is produced by the program running on the server.

        Most likely you are sending unexpected data to the remote side and the remote side does not know how to handle this.

Re: I got HTTP POST error message: Internal Server Error
by poj (Abbot) on Sep 19, 2014 at 10:51 UTC
    "value" : "001695568GP", ^ missing quote
    poj
Re: I got HTTP POST error message: Internal Server Error
by derby (Abbot) on Sep 19, 2014 at 10:52 UTC

    Maybe a typo but you have bad JSON:

    "value" : "001695568GP,
    is missing the closing quote.

    -derby
Re: I got HTTP POST error message: Internal Server Error
by Anonymous Monk on Sep 19, 2014 at 03:50 UTC

    Well, examine more of the headers and content than merely the error code and message

    This is the beginning

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1101140]
Approved by biohisham
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2022-05-18 23:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (71 votes). Check out past polls.

    Notices?