Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Proper way to add link to _links section

edited December 2018 in SRP HTTP Framework
I created some custom scripting to fetch a collection for an Item. I would like to add this URL to the _links section of the item. I found SetHALLinks in http_json_services which should be able to do this. So in my http service, the GetItem now looks like this:

GetItem: ItemID = NextSegment // Add to _links Http_Json_Services('SetHALLinks', SelfURL : '/' : ItemID, 'lijst', SelfURL : '/' : ItemID:'/lijst') HAL = HTTP_Resource_Services('GetDatabaseItem', 'LBD007', SelfURL : '/' : ItemID, ItemID, ColumnNames) // Use the Response variable for internal monitoring, tracking, and debugging. This does not affect the HTTP // response. Response = HAL return

It seems that the links are being overwritten though when the hal item is being set within GetDatabaseItem.

So in Http_Json_Services I changed the SetHALItem code a bit, at line 120:

If Error_Services('NoError') then If Len(HALRootLinksObj@) else SRP_JSON(HALRootLinksObj@, 'NEW', 'OBJECT') end // Create the "_links" object. It will be SET to the root object in the GetHAL service. If Len(HALRootLinksObj@) then // Create the "self" object. It will be SET to the "_links" object when finished. If SRP_JSON(hSelfObj, 'NEW', 'OBJECT') then ...

Is this the right approach?


  • Bottom line, if it is working the way you want then it is the right approach. We've significantly overhauled this logic in the upcoming v4 version of the HTTP Framework so none of the original logic related to these services looks the same. I'll just say this, one of the design changes we made was to make it much easier to add _links relationships to a JSON representation...exactly what you are trying to do in your own code.
Sign In or Register to comment.