Commit 44b2df48 authored by Guillaume Huard's avatar Guillaume Huard
Browse files

push prototype

parent 52bca793
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
use Data::Dumper;
use File::Slurp;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
my $url = 'https://moodle.caseine.org/webservice/rest/server.php';
my $vplid='19435';
my $token='3d610600e046a8669cb39ec4798f8a56';
my $ua = LWP::UserAgent->new( agent => 'Secret');
my $res = $ua->post( $url,
Content_Type => 'form-data',
Content => [
moodlewsrestformat => 'json',
id => "$vplid",
wstoken => "$token",
wsfunction => 'mod_vpl_set_setting',
settingname => 'name',
settingvalue => 'Essai',
],
);
# print Dumper($res);
my $data = read_file('./local.sh');
my $res = $ua->post( $url,
Content_Type => 'form-data',
Content => [
moodlewsrestformat => 'json',
id => "$vplid",
wstoken => "$token",
wsfunction => 'mod_vpl_save_execution_files',
"files[0][name]" => 'local.sh',
"files[0][data]" => "$data",
],
);
# Classic post does not work
# my $data = read_file('./local.sh');
# my $res = $ua->post( $url,
# Content_Type => 'form-data',
# Content => [
# moodlewsrestformat => 'json',
# id => "$vplid",
# wstoken => "$token",
# wsfunction => 'mod_vpl_save_execution_files',
# "files[0]" => [ './local.sh', 'local.sh' ],
# ],
# );
print Dumper($res);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment