---
name: "Catmandu::FedoraCommons::Response"
section: "3pm"
platform: "linux"
package: "libcatmandu-fedoracommons-perl"
version: "0.5-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Catmandu::FedoraCommons::Response"
---

# Catmandu::FedoraCommons::Response(3pm)

Perl model for generic Fedora Commons REST API responses

## NAME

Catmandu::FedoraCommons::Response - Perl model for generic Fedora Commons REST API responses

## SYNOPSIS

```
  use Catmandu::FedoraCommons;

  my $fedora = Catmandu::FedoraCommons->new('http://localhost:8080/fedora','fedoraAdmin','fedoraAdmin');

  my $result = $fedora->findObjects(terms=>'*');

  die $resut->error unless $result->is_ok;

  my $obj = $result->parse_content;

  $result->is_ok;
  $result->error;
  $result->raw;
  $result->content_type;
  $result->length;
  $result->date;
  $result->parse_content();
  $result->parse_content($my_model);
```

## DESCRIPTION

A Catmandu::FedoraCommons::Response gets returned for every Catmandu::FedoraCommons method. This response contains the raw HTTP content of a Fedora Commons request and can also be used to parse XML responses into Perl objects using the parse\_content function. For more information on the Perl objects see the information in the Catmandu::FedoraCommons::Model packages.

### METHODS

### is\_ok()

Returns true when the result Fedora Commons response contains no errors.

### error()

Returns the error message of the Fedora Commons response if available.

### parse\_content($model)

Returns a Perl representation of the Fedora Commons response. Optionally a  model object can be provided that implements a `$obj`-\>parse($bytes) method and returns a Perl object. If no model is provided then default  models from the Catmandu::FedoraCommons::Model namespace are used.

```
 Example:
 package MyParser;

 sub new {
     my $class = shift;
     return bless {} , $class;
 }

 sub parse {
     my ($self,$bytes) = @_;
     ...
     return $perl
 }

 package main;

 my $fedora = Catmandu::FedoraCommons->new('http://localhost:8080/fedora','fedoraAdmin','fedoraAdmin');
 my $result = $fedora->findObjects(terms=>'*');

 my $perl = $result->parse_content(MyParser->new);
```

### raw()

Returns the raw Fedora Commons response as a string.

### content\_type()

Returns the Content-Type of the Fedora Commons response.

### length()

Returns the byte length of the Fedora Commons response.

### date()

Returns the date of the Fedora Commons response.

## AUTHORS

- •

  Patrick Hochstenbach, `"<patrick.hochstenbach at ugent.be>"`

## SEE ALSO

Catmandu::Model::findObjects, Catmandu::Model::getObjectHistory, Catmandu::Model::getObjectPrifule, Catmandu::Model::listDatastreams, Catmandu::Model::listMethods
