1

We are facing a serious issue with GREG's Governance REST API. Below are the exact issue scenario and other details for a quick resolution.

We wanted to add few custom fields in the "restservice" Artifact of RXT file hence we have added in the .rxt file also we successfully able to pass value to the added custom fields through Governance REST API call (https://localhost:9443/governance/restservices)-POST operation but while performing update(same URL using PUT operation) operation for the added restservice using UUID the previously added data are getting wiped off.

Product Details: WSO2 Governance Registry 5.3.0 API Name: Governance REST API

Community
  • 1
  • 1

1 Answers1

2

If you want to partially update the asset, relevant HTTP operation is HTTP PATCH. However, Governance REST API doesn't support HTTP PATCH operation yet. So first you have to get the asset data using HTTP GET and after that, you can update relevant attributes in given asset using HTTP PUT operation.

Chandana
  • 2,578
  • 8
  • 38
  • 55
  • Happy to see that this potential bog got fixed in short time. Many thanks Chandana. I'm new to build process so would you mind providing detailed step by step process on pulling code from your Github and Build process. – Mathan Prasath Sep 24 '16 at 05:46
  • As part of the above fix, we are trying to Build the code using Maven but when doing so it throws the below error saying artifacts not found. Error:::: The following artifacts could not be resolved:org.wso2.carbon.registry.common-4.6.1-SNAPSHOT.jar org.wso2.carbon.registry.admin.api-4.6.1-SNAPSHOT.jar org.wso2.carbon.registry.extensions-4.6.1-SNAPSHOT.jar org.wso2.carbon.registry.indexing-4.6.1-SNAPSHOT.jar. Kindly help to resolve asap. – Mathan Prasath Sep 27 '16 at 10:07
  • I could see you have reverted the changes. Not sure why? Could you please confirm here about it? It's seriously a Bug and while doing PUT operation the previously added data (POST) should not be deleted. Kindly confirm the same asap. Thanks in advance. – Mathan Prasath Sep 28 '16 at 05:42
  • I believe below is your updated comment.==If you want to partially update the asset, relevant HTTP operation is HTTP PATCH. However, Governance REST API doesn't support HTTP PATCH operation yet. So first you have to get the asset data using HTTP GET and after that, you can update relevant attributes in given asset using HTTP PUT operation. ==== But as per the REST principles, a PUT operation should only update the parameters and should not wipe the previously added value of parameters. This is what happening in GERG 5.3.0. Kindly clarify us. thanks – Mathan Prasath Sep 28 '16 at 10:41
  • Kindly respond. – Mathan Prasath Sep 29 '16 at 04:11
  • If you are not parsing the complete set of parameters to the `PUT` operation, that means you want to remove those attributes from the asset. To update the selected attributes, you have to use ` HTTP PATCH` , but currently, Governance REST API doesn't support `HTTP PATCH` operation yet as explained in my answer. – Chandana Sep 29 '16 at 06:19
  • As per the REST principles, PUT operation updates the value of a field if it exists, else it will create a new field and assign value to it. But in the case of GREG PUT method, when we try updating a field value, it updates the value but also wipes off the other field values. This should not happen. Hope I'm sensible here. – Mathan Prasath Sep 29 '16 at 06:27
  • You must provide the complete resource with HTTP PUT operation. "PUT is a much more restrictive verb. It takes a complete resource and stores it at the given URL." http://www.philandstuff.com/2011/04/14/put-vs-post.html – Chandana Sep 29 '16 at 08:52
  • I have referred the above Article. Taken the below point for your reference. "PUT is a much more restrictive verb. It takes a complete resource and stores it at the given URL. If there was a resource there previously, it is replaced; if not, a new one is created". But what happens in GREG PUT is it's not only replacing a value of the resource but also wiping off the previously added values to the same resource. . – Mathan Prasath Sep 29 '16 at 12:16
  • Let me say a scenario, I have added 5 parameters to an artifact as part of POST operation and want to update only one parameter in that Artifact, when I'm doing so with PUT method, it goes and updates that particular parameter also removes the value of other 4 parameter. This is the issue I'm trying to point out Chandana – Mathan Prasath Sep 29 '16 at 12:16
  • If you are doing a put operation, you must parse all 5 parameters. – Chandana Sep 29 '16 at 12:19
  • Let me revisit my comments and come up with actual scenario. This Scenario goes like this, Using POST method we are sending a Payload(Contains 10 key/value pairs in JSON format) to create a stuff inside GREG and now we want to update only the 10th key/value pair so using PUT operation, we are doing update to the previously created stuff. After the PUT operation the previously added all 9 Key/value pairs are wiped off and only the 10th Key/value pair remains. This is the exact issue scenario and why do we need to send all the 9key/value pairs when we just want to update only the one parameter. – Mathan Prasath Sep 30 '16 at 04:46
  • 1
    Yes, you must send all the attributes( 10 key/value pairs) – Chandana Sep 30 '16 at 04:48
  • Is WSO2 Governance Registry's REST API's built based on standard REST Principles ? I'm taking the reference of Roy Fielding one of the principal authors of HTTP specification. – Mathan Prasath Sep 30 '16 at 04:50
  • I don't know what is stopping you to agree that this is a Bug in your product? – Mathan Prasath Sep 30 '16 at 04:55
  • 1
    According to [RFC 5789](https://tools.ietf.org/html/rfc5789), `PUT` method is described as, Several applications extending the Hypertext Transfer Protocol (HTTP) require a feature to do partial resource modification. **The existing HTTP PUT method only allows a complete replacement of a document.** This proposal adds a new HTTP method, PATCH, to modify an existing HTTP resource. – madawa Oct 06 '16 at 11:46
  • Yes, please. When can we expect the partial modification feature as I understand current version of WSO2 GREG doesn't have this support? We desperately in need of this support(HTTP PATCH)in WSO2 GREG. – Mathan Prasath Oct 11 '16 at 06:48