Subject: | application/json expected |
When calling create_doc i always get an error from couchdb:
application/json expected
so, i reimplemented _call:
sub _call {
my $self = shift;
my $method = shift;
my $uri = shift;
my $content = shift;
my $req = HTTP::Request->new($method, $uri);
if(defined $content) {
$req->header( 'Content-Type' => 'application/json' );
$req->content(Encode::encode('utf8', $content))
}
my $ua = LWP::UserAgent->new();
my $return = $ua->request($req);
my $response = $return->decoded_content({
default_charset => 'utf8'
});
my $decoded;
eval {
$decoded = $self->json()->decode($response);
};
if ($@) {
return {error => $return->code, reason => $response};
}
return $decoded;
}