tags:

views:

92

answers:

1

I've built a REST Server and now I want to rapidly test it from a Perl Client, using REST::Client module.

It works fine if I perform GET Request (explicitly setting parameters in the URL) but I can't figure out how to set those params in POST Requests.

This is how my code looks like:

#!/usr/bin/perl
use strict;
use warnings;

use REST::Client;

my $client = REST::Client->new();

my $request_url =  'http://myHost:6633/my_operation';

$client->POST($request_url); 
print $client->responseContent();

I've tried with something similar to:

$client->addHeader ('my_param' , 'my value');

But it's clearly wrong since I don't want to set an HTTP predefined Header but a request parameter.

Thank you!

A: 

I've not used the REST module, but looking at the POST function, it accepts a body content parameter, try creating a string of the parameters and send that within the function

$client->POST($request_url, "my_param=my+value"); 
print $client->responseContent();
Psytronic