Skip to content

Error parsing response #121

@rbetancor

Description

@rbetancor

Hi all, I'm trying to use Hyperclient to consume the API of a server that it's build with perl+Catalyst and exposes outside as JSON+HAL, but I'm stuck with a parsing error that Hyperclient throw me and I'm unnable to figure what's happen.

This is the full response when I query the resource 'subscribers':

{
   "_embedded" : {
      "ngcp:subscribers" : [
         {
            "_links" : {
               "collection" : {
                  "href" : "/api/subscribers/"
               },
               "curies" : {
                  "href" : "http://purl.org/sipwise/ngcp-api/#rel-{rel}",
                  "name" : "ngcp",
                  "templated" : true
               },
               "ngcp:callforwards" : {
                  "href" : "/api/callforwards/52"
               },
               "ngcp:calls" : {
                  "href" : "/api/calls/?subscriber_id=52"
               },
               "ngcp:customers" : {
                  "href" : "/api/customers/3"
               },
               "ngcp:domains" : {
                  "href" : "/api/domains/3"
               },
               "ngcp:journal" : {
                  "href" : "/api/subscribers/52/journal/"
               },
               "ngcp:reminders" : {
                  "href" : "/api/reminders/?subscriber_id=52"
               },
               "ngcp:subscriberpreferences" : {
                  "href" : "/api/subscriberpreferences/52"
               },
               "ngcp:subscriberregistrations" : {
                  "href" : "/api/subscriberregistrations/?subscriber_id=52"
               },
               "ngcp:voicemailsettings" : {
                  "href" : "/api/voicemailsettings/52"
               },
               "profile" : {
                  "href" : "http://purl.org/sipwise/ngcp-api/"
               },
               "self" : {
                  "href" : "/api/subscribers/52"
               }
            },
            "administrative" : false,
            "alias_numbers" : [],
            "customer_id" : 3,
            "domain" : "proxy.testserver.org",
            "domain_id" : 3,
            "email" : null,
            "external_id" : null,
            "id" : 52,
            "password" : "testtest",
            "primary_number" : {
               "ac" : "949",
               "cc" : "1",
               "sn" : "3465301"
            },
            "profile_id" : null,
            "profile_set_id" : null,
            "status" : "active",
            "username" : "test.fax",
            "uuid" : "45cdcf6f-3f39-4245-bccb-3db775622701",
            "webpassword" : null,
            "webusername" : "test.fax"
         },
         {
            "_links" : {
               "collection" : {
                  "href" : "/api/subscribers/"
               },
               "curies" : {
                  "href" : "http://purl.org/sipwise/ngcp-api/#rel-{rel}",
                  "name" : "ngcp",
                  "templated" : true
               },
               "ngcp:callforwards" : {
                  "href" : "/api/callforwards/55"
               },
"ngcp:calls" : {
                  "href" : "/api/calls/?subscriber_id=55"
               },
               "ngcp:customers" : {
                  "href" : "/api/customers/3"
               },
               "ngcp:domains" : {
                  "href" : "/api/domains/3"
               },
               "ngcp:journal" : {
                  "href" : "/api/subscribers/55/journal/"
               },
               "ngcp:reminders" : {
                  "href" : "/api/reminders/?subscriber_id=55"
               },
               "ngcp:subscriberpreferences" : {
                  "href" : "/api/subscriberpreferences/55"
               },
               "ngcp:subscriberregistrations" : {
                  "href" : "/api/subscriberregistrations/?subscriber_id=55"
               },
               "ngcp:voicemailsettings" : {
                  "href" : "/api/voicemailsettings/55"
               },
               "profile" : {
                  "href" : "http://purl.org/sipwise/ngcp-api/"
               },
               "self" : {
                  "href" : "/api/subscribers/55"
               }
            },
            "administrative" : false,
            "alias_numbers" : [],
            "customer_id" : 3,
            "domain" : "proxy.testserver.org",
            "domain_id" : 3,
            "email" : null,
            "external_id" : null,
            "id" : 55,
            "password" : "tfp6LzOxTFa2OWHF",
            "primary_number" : {
               "ac" : "919",
               "cc" : "1",
               "sn" : "8675959"
            },
            "profile_id" : null,
            "profile_set_id" : null,
            "status" : "active",
            "username" : "7WOkIWgU",
            "uuid" : "df0ed22e-d0db-406b-b1cf-0f068f5778d4",
            "webpassword" : null,
            "webusername" : "7WOkIWgU"
         }
      ]
   },
   "_links" : {
      "curies" : {
         "href" : "http://purl.org/sipwise/ngcp-api/#rel-{rel}",
         "name" : "ngcp",
         "templated" : true
      },
      "ngcp:subscribers" : [
         {
            "href" : "/api/subscribers/52"
         },
         {
            "href" : "/api/subscribers/55"
         }
      ],
      "profile" : {
         "href" : "http://purl.org/sipwise/ngcp-api/"
      },
      "self" : {
         "href" : "/api/subscribers/?page=1&rows=10"
      }
   },
   "total_count" : 2
}

And this is the error Hyperclient throw me when I try to do a simple iteration over api.subscribers.each to just puts the subscriber.id:

RuntimeError: Invalid response for LinkCollection. The response was: "_links"
from /usr/local/rvm/gems/ruby-2.3.3/gems/hyperclient-0.8.5/lib/hyperclient/link_collection.rb:18:in `initialize'

Why it's unable the full parse the response and let my iterate over the subscribers collection ? ... I've checked that the response is ok.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions