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
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:
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:
Is this the right approach?
GetItem:
ItemID = NextSegment
// Add http://127.0.0.1/api/lijn/4/lijst 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?
Comments