<div dir="ltr">Hi William,<div>You can check your $response for more details on the failure. Specifically:</div><div><br></div><div>die "Failed: ", $response->{content}, "\n" unless $response->{success};</div><div><br></div><div>This is a guess, based on past work with Perl and web APIs, but you probably need to install some modules to support the https protocol. From the HTTP::Tiny docs, you'll need IO::Socket::SSL and Net::SSLeay. <a href="https://metacpan.org/pod/HTTP::Tiny#SSL-SUPPORT" target="_blank">https://metacpan.org/pod/HTTP::Tiny#SSL-SUPPORT</a></div><div><br></div><div>-collin</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Nov 20, 2022 at 7:38 AM William Michels <<a href="mailto:wjm1@caa.columbia.edu" target="_blank">wjm1@caa.columbia.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<br><br>I'm trying to get the example Perl5 code from the bottom of this REST-API page to work:<br><br><a href="https://rest.ensembl.org/documentation/info/archive_id_post" target="_blank">https://rest.ensembl.org/documentation/info/archive_id_post</a><br><br><span style="font-family:arial,sans-serif">I can get the example curl, wget, and R code to work from the same page, so I know the server (<a href="https://rest.ensembl.org" target="_blank">https://rest.ensembl.org</a>) is up and running. Below is the code, cut-and-pasted. I had to install the JSON module. All I get back is the string "Failed!" while <span style="font-family:arial,sans-serif">curl, wget, and R all return actual data</span>:</span><br><div><br></div><div><br></div><span style="font-family:monospace">use strict;<br>use warnings;<br> <br>use HTTP::Tiny;<br> <br>my $http = HTTP::Tiny->new();<br> <br>my $server = '<a href="https://rest.ensembl.org" target="_blank">https://rest.ensembl.org</a>';<br>my $ext = '/archive/id';<br>my $response = $http->request('POST', $server.$ext, {<br>  headers => {<br>      'Content-type' => 'application/json',<br>      'Accept' => 'application/json'<br>  },<br>  content => '{ "id" : ["ENSG00000157764", "ENSG00000248378"] }'<br>});<br> <br>die "Failed!\n" unless $response->{success};<br> <br> <br>use JSON;<br>use Data::Dumper;<br>if(length $response->{content}) {<br>  my $hash = decode_json($response->{content});<br>  local $Data::Dumper::Terse = 1;<br>  local $Data::Dumper::Indent = 1;<br>  print Dumper $hash;<br>  print "\n";<br>}<br> </span><br><br><br></div>
_______________________________________________<br>
SanFrancisco-pm mailing list<br>
<a href="mailto:SanFrancisco-pm@pm.org" target="_blank">SanFrancisco-pm@pm.org</a><br>
<a href="https://mail.pm.org/mailman/listinfo/sanfrancisco-pm" rel="noreferrer" target="_blank">https://mail.pm.org/mailman/listinfo/sanfrancisco-pm</a><br>
</blockquote></div>