Hello,
I am encountering a weird thing going on with GET vs POST request. I have the following agent code:
`
function requestHandler(request, response) {
try {
// check if the user sent Hardware_Reset as a query parameter
server.log(“All good - 1”);
// if (“Test1” in request.query)
if (“Test1” in request.query)
{
server.log(“All good - 2”);
if (request.query.Test1== “0” || request.query.Test1 == “1”)
{
server.log(“All good - 3”);
}
}
// send a response back saying everything was OK.
response.send(200, “OK”);
} catch (ex) {
response.send(500, "Internal Server Error: " + ex);
}
}
// register the HTTP handler
http.onrequest(requestHandler);
`
Now, if I go to the internet and type the following into the web browser:
https://agent.electricimp.com/MYAGENTLINK?Test1=0
I get the following output in the server logs: This is a GET request
All good - 1
All good - 2
All good - 3
Now if I use a perl program to do the same thing, I only get the following output:
All good - 1
This is the perl program that I am using:
`
#************************************************
#**************** Send_Request********************
#************************************************
sub Send_Request
{
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $url = 'https://agent.electricimp.com/'.$Agent_Link;
my $req = ('Garage_Door_ID' => '0');
my $response = $ua->post($url,$req);
Check the response
if ($response->code() == 200) #$response->code will return 200 for OK (this is set within the IMP Agent Code)
{
print $response->code(); #Change this line of code to do whatever I want
}
}
1;
`
So why is the “All good -2” and “All good -3” dropping out from the POST request, but not the GET request. How do I make this work with the POST request?
Thanks