2 Replies Latest reply on Jul 7, 2017 3:53 AM by Brun

    Adding custom link entries and url variable

    Brun

      Hi,

       

      i have a paginated sql query service where i want to add additional custom entries into "links" section of the output which will navigate to related services.

       

      I have seen this done before with a variable for the url so its not environment specific but i cannot find or remember how to do it.

       

      see below example, where attributes is the added link to another service.

       

      {
      "items" : [{
      "product_id" : 17964660
      }
      ],
      "hasMore" : false,
      "limit" : 500,
      "offset" : 0,
      "count" : 1,
      "links" : [{
      "rel" : "self",
      "href" : "https://myordstst/ords/schema/web/products?product_id=17964660"
      }, {
      "rel" : "describedby",
      "href" : "https://myordstst/ords/schema/metadata-catalog/web/products/item"
      }, {
      "rel" : "first",
      "href" : "https://myordstst/ords/schema/web/products?product_id=17964660"
      }, {
      "rel" : "attributes",
      "href" : "https://myordstst/ords/schema/web/product_attributes?product_id=17964660"
      }
      ]
      }
      
        • 1. Re: Adding custom link entries and url variable
          Kiran Pawar

          Hi Brun,

          Brun wrote:

           

          i have a paginated sql query service where i want to add additional custom entries into "links" section of the output which will navigate to related services.

          I have seen this done before with a variable for the url so its not environment specific but i cannot find or remember how to do it.

          see below example, where attributes is the added link to another service.

          Are you talking about $uri to linking the column value in one RESTful Web Service to another RESTful Web Service.

          Refer: http://www.thatjeffsmith.com/archive/2017/05/ords-restful-services-and-uri/

           

          Hope this helps!

           

          Regards,

          Kiran

          • 2. Re: Adding custom link entries and url variable
            Brun

            Perfect that's exactly what i was looking for.

             

            See below my example.

             

            Example Service SQL

            select product_id,
                  '../product_attributes/' || :site_name || '/' || p.product_id "$product_attributes",
                  '../product_images/'     || :site_name || '/' || p.product_id "$product_images"            
            from myproducts 
            where site_name = upper(:site_name)
            and product_id = :product_id
            

             

            Example Response

            {      "items" : [{                "product_id" : 38991,                "links" : [{                          "rel" : "product_attributes",                          "href" : "https://myordstst/ords/schema/web/product_attributes/site/38991"                     }, {                          "rel" : "product_images",                          "href" : "https://myordstst/ords/schema/web/product_images/site/38991"                     }                ]           }      ],      "hasMore" : false,      "limit" : 500,      "offset" : 0,      "count" : 1,      "links" : [{                "rel" : "self",                "href" : "https://myordstst/ords/schema/web/products/site?product_id=38991"           }, {                "rel" : "describedby",                "href" : "https://myordstst/ords/schema/metadata-catalog/web/products/item"           }, {                "rel" : "first",                "href" : "https://myordstst/ords/schema/web/products/site?product_id=38991"           }      ] }