API SERVICE: How to specify in endpoint URL correct sort value for related objects

Hi support,
We have a digital documental project with Providence version 1.6.3 and we want show some data collected into his database by using the API Service.
Sorry, but reading the guide at URL http://docs.collectiveaccess.org/wiki/Web_Service_API#Getting_item-level_data and the section Types of information, note 4 Related items, at URL http://docs.collectiveaccess.org/wiki/API:Accessing_Data, I don't have unsterstood what to do with related objects.

I try to explaine what We need.

Doing this request:

I retrieve the data of one object (related to ca_list_items: list object_types and id cas_obj_monument), related to another object (related to ca_list_items: list object_types and id cas_obj_site):
{
  "ok":true,
  "preferred_labels":{ "it_IT":[ { "name":"Piazzale del Teatro (Sabratha)" } ] },
  "object_id":{ "value":"586" },
  "intrinsic":{
    "object_id":"586",
    "hier_object_id":"586",
    "type_id":"213",
    "idno":"Piazzale del teatro",
    ...
  },
  "type_id":{                                  (( this is an "object_types" which id value is "cas_obj_monument" ))
    "value":"213",
    "display_text":{ "it_IT":"Monumento Archeologico" }
  },
  ...
  "related":{
    "ca_objects":[
      {
        "item_type_id":"209",          (( this is an "object_types" which id value is "cas_obj_site" ))
        "object_id":"21",
        "relationship_type_id":"127",
        "idno":"Sabratha",
        "idno_sort":"Sabratha    ",
        "relation_id":"2038",
        "name":"Sabratha",
        "locale_id":"11",
        "row_id":"586",
        "rank":"2038",
        "labels":{ "11":"Sabratha" },
        "_key":"relation_id",
        "direction":"ltor",
        "relationship_typename":"is related to",
        "relationship_type_code":"related",
        "label":"Sabratha",
        "representations":[
        ]
      },
      ...
     ]
   }
}

With the APIs, I need to get all the objects grouped by object_types.cas_obj_monument and sorted primarily by the related grouping object_types.cas_obj_site.
How could I get this sort?

This is the request I use to get all objects grouped by object_types.cas_obj_monument (q parm in querystring):
http://<server>/service.php/find/ca_objects/?lang=it_IT&pretty=1&sort=<item_type_id cas_obj_site>;ca_object_labels.name_sort&summary=1&q=cas_obj_monument&ca_objects.is_enabled=1"

This are the bundles I add into the CURL (PHP):
CURLOPT_POSTFIELDS = "{
"bundles" : {
"access" : { "convertCodesToDisplayText" : true },
"status" : { "convertCodesToDisplayText" : true },
        "<item_type_id cas_obj_site>" : { "returnAsArray" : false },
"ca_object_labels.name" : {"returnAsArray" : true },
"ca_object_labels.name_sort" : {"returnAsArray" : true }
}
}"

With what should I replace "<item_type_id cas_obj_site>" in the request and bundles data ?
Thanks and best regards.

Comments

  • Hi support, 
    you don't have suggestions to solve this problem ?
  • Hi,

    I saw your recent post about new services in 2.0 and referencing this un-answered question. I'm afraid I can't really understand what you're asking for here. It sounds like you're trying to get a list of objects of type "cas_obj_monument" grouped by the name of of an object of type "cas_obj_site" related to each monument?
  • Hi Seth, 
    thanks for your reply. 

    Nearly!
    I wanted to say that the list of objects to retrieve by the API will have to be ordered:
    1) by the value of cas_obj_site 's label 
    2) by the value of cas_obj_monument 's label


    I've done a similar thing by this call: 
    /service.php/find/ca_objects/?lang=it_IT&pretty=1&sort=ca_objects.cas_cont_coll_jour.cas_cont_coll_jour_ann;ca_object_labels.name_sort&summary=1&q=cas_obj_jour

    having this bundles in CURLOPT_POSTFIELDS: 
    {
    "bundles" : {
    "access" : { "convertCodesToDisplayText" : true },
    "status" : { "convertCodesToDisplayText" : true },
    "ca_objects.cas_cont_coll_jour.cas_cont_coll_jour_ann" : { "returnAsArray" : false },
    "ca_object_labels.name" : {"returnAsArray" : true },
    "ca_object_labels.name_sort" : {"returnAsArray" : true }
    }
    }


    But do not have found the way to do with cas_obj_site and cas_obj_monument.
    Do You think is it possible for this last?
    • File upload via REST API
Sign In or Register to comment.