|
Post by jdoman on Feb 24, 2021 18:27:19 GMT
What request should a client send to modify a link to a sub-resource? Specifically I'm looking at Processor AppliedOperatingConfig which looks like this:
{ "@odata.id": "/redfish/v1/Systems/system/Processors/cpu0", "@odata.type": "#Processor.v1_11_0.Processor", "AppliedOperatingConfig": { "@odata.id": "/redfish/v1/Systems/system/Processors/cpu0/OperatingConfigs/config0" }, ... }
In order to update the AppliedOperatingConfig, I assumed the client would send this PATCH body to the Processor URL:
{ "AppliedOperatingConfig": { "@odata.id": "/redfish/v1/Systems/system/Processors/cpu0/OperatingConfigs/config3" } } But this looks a little unusual, and I can't find any place in the Redfish spec or odata spec that clearly explains how to do this (but I'm not a REST expert and much of those specs goes over my head).
Can anyone point to a specific point in the spec or provide the correct request to do this?
|
|
|
Post by jautor on Feb 25, 2021 21:57:08 GMT
Yes, that looks correct. The PATCH request is just updating the value of a property - in this case the "@odata.id" property. Since that property is embedded in a JSON object (the "AppliedOperatingConfig" object-type property), you have to include that hierarchy in the PATCH as well.
Jeff
|
|
|
Post by jdoman on Feb 25, 2021 23:34:05 GMT
Thanks for the reply. I have another follow up question: if the server has to reject the PATCH for some reason and needs to return an error message (e.g. PropertyValueIncorrect), which property name and value should it reference in the response?
Does this look correct?
{ "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The property 'AppliedOperatingConfig' with the requested value of '{"@data.id":"/redfish/v1/Systems/system/Processors/cpu0/OperatingConfigs/config99"}' could not be written because the value does not meet the constraints of the implementation.", "MessageArgs": [ "AppliedOperatingConfig", "{"@data.id":"/redfish/v1/Systems/system/Processors/cpu0/OperatingConfigs/config99"}" ], "MessageId": "Base.1.8.1.PropertyValueIncorrect", "MessageSeverity": "Warning", "Resolution": "No resolution is required." } ], "code": "Base.1.8.1.PropertyValueIncorrect", "message": "The property 'AppliedOperatingConfig' with the requested value of '{"@data.id":"/redfish/v1/Systems/system/Processors/cpu0/OperatingConfigs/config99"}' could not be written because the value does not meet the constraints of the implementation." } } If there were any other properties in the sub-object then this would be an ambiguous message. But I don't know if there is any property with such a format - maybe it's not a concern.
EDIT: perhaps it would need some more JSON/quote escaping - but the question is should it reply with the whole sub-object?
|
|
|
Post by mraineri on Feb 26, 2021 18:44:20 GMT
In the error response, it also looks like you're missing the letter "o" in "@odata.id". Overall, the general pattern is correct, and it likely is complaining about some nit.
Can you try with curl with this exact string for the --data argument?
--data '{ "AppliedOperatingConfig": { "@odata.id": "/redfish/v1/Systems/system/Processors/cpu0/OperatingConfigs/config99" } }'
|
|
|
Post by jdoman on Feb 26, 2021 23:14:13 GMT
Yeah, I didn't explain fully but I'm working on the server implementation and just checking to make sure I do it correctly. I constructed that response message manually by copy/pasting the property/value I was referring to. But thanks for the replies - sounds like I was on the right path.
|
|