POST/PUT Requirement with a Custom Attribute Using REST API / OSLC
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:oslc_rm="http://open-services.net/ns/rm#"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:rm_property="https://research.jazz:9443/rm/types/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<oslc_rm:Requirement
rdf:about="">
<dc:title>MyDocument</dc:title>
<dc:description>This is a test document</dc:description>
<oslc:instanceShape rdf:resource="https://research.jazz:9443/rm/types/_6t0UYJUTEeGjDYB2VGA7DA"/>
<rm_property:_ycrkq5UTEeGjDYB2VGA7DA rdf:parseType="Literal"><div xmlns="http://www.w3.org/1999/xhtml" id="_Nf2cQJKNEd25PMUBGiN3Dw"><h1 id="_DwpWsMueEd28xKN9fhQheA">Test Document</h1></div></rm_property:_ycrkq5UTEeGjDYB2VGA7DA>
</oslc_rm:Requirement>
</rdf:RDF>
We have a custom attribute called
How do we do it? Is there something like the following we can use along with the above body?
<rm_property:_6m0UhJUTEeGjDYB2VGA7DA rdf:parseType="Literal">High</rm_property:_6m0UhJUTEeGjDYB2VGA7DA>
We understand that the above format is not correct. What is the correct format we should use?
8 answers
For Data Types that have specific ( allowed ) values, users must specify the corresponding UUID for that value.
For instance in my environment a requirement expose following property :
<rm_property:_Djd1ANDhEeGe18MmgIPNSw rdf:resource="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#e28b500e-77af-4f34-86f4-2ef1f70ad3dc"/>
The Property Type ( Bold) and its value (Italics) is specified by the rdf:resource :
"https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#e28b500e-77af-4f34-86f4-2ef1f70ad3dc"
To get the allowed values for a specific type do a get to the Resource type ( Bold ):
"https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw"
It will return the allowed values and the complete URI to be used in a POST create ) or a PUT ( change ) that value in an artifact
PLS let me know if questions.
Comments
Gabriel
Can you provide an example of the return results from a GET on the resource type? I want to see what you mean by 'specify the corresponding UUID for the allowed value'.
Can you also take a look at Arun's last comment and see what he did wrong after retrieving the list of allowed values?
1 vote
Output :
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:acp="http://jazz.net/ns/acp#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw">
<acp:accessControl rdf:resource="https://gradev.ibm.com:9444/rdm/accessControl/_OcYF0sSMEeGA8-GkKWmlAA"/>
<rdfs:comment></rdfs:comment>
<rdfs:label>GRADATATYPE</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#2f257129-a0ee-4d8c-8d47-a72797f034ef">
<rdfs:comment></rdfs:comment>
<rdfs:label>4</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#e28b500e-77af-4f34-86f4-2ef1f70ad3dc">
<rdfs:comment></rdfs:comment>
<rdfs:label>1</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#9f02a905-9f06-4c31-873b-49fe8c8e36bb">
<rdfs:comment></rdfs:comment>
<rdfs:label>5</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#716d95cb-f50c-484e-8d0e-527702c1bff0">
<rdfs:comment></rdfs:comment>
<rdfs:label>2</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#17d50781-6691-4862-8041-ff9fb7dd04d1">
<rdfs:comment></rdfs:comment>
<rdfs:label>3</rdfs:label>
</rdf:Property>
</rdf:RDF>
In case user wants to set label 3, then user must specify the rdf:value for it:
"https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#17d50781-6691-4862-8041-ff9fb7dd04d1"
Regarding Arun's last comment, a real value is being used and that is not allowed.
<pre>
<rm_property:_6m0UhJUTEeGjDYB2VGA7DA rdf:parseType="Literal">High</rm_property:_6m0UhJUTEeGjDYB2VGA7DA>
</pre>
in that case, you can very well include it within the body when you POST or PUT.
Comments
But if i do this, it gives me a "403 Forbidden" error. rdf:parseType="Literal" is something i have copied from other lines in the body and i guess this is not the correct way to enter the value of a custom attribute . Moreover i do not know whether the value "High" will be directly acceptable.
Could you please elaborate. All I have is the property id, rm_property:_6m0UhJUTEeGjDYB2VGA7DA
The custom attribute is of the data type "Enumerated list of values".
Can you elaborate on the custom attribute that you added? If you query with https://research.jazz:9443/rm/types/_6t0UYJUTEeGjDYB2VGA7DA with GET, you should get all the type definition for all the attributes and in that case, you shall be clear on this whether it is Literal or not.
Next i used GET on the propertyDefinition (https://research.jazz:9443/rm/types/_6m0UhJUTEeGjDYB2VGA7DA) and i received the following response
I request you to assist on how to create the correct format.
Thank You,
Arun
Comments
@ArunBatra: You should not put your clarifications as answer to your own question. You could edit the question and add the clarifications below it. The keeps thing intact.
Ya sorry, the size was to big for the comment. I will keep the edit option in mind though. Thank You.
Comments
I used <rm_property:_6m0uhjuteegjdyb2vga7da rdf:parsetype="int">0</rm_property:_6m0uhjuteegjdyb2vga7da> in the body to post a requirement, i got the 403 Forbidden again. When i excluded this from the body, the requirement created successfully. (i.e. without the custom attribute being set).
This is not the correct format either.
What can we try now?
Hi Kangkan, This has become a major blocker for us. We would be grateful for any help we can get.
Still trying to work on it....
1 vote
Possibility for any solution?
I am able to create a requirement with a custom attribute value.
This is the line that worked for me.
<rm_property:_6m0UhJUTEeGjDYB2VGA7DA rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA#85f26fb6-2f9c-40db-83ff-aefe1ab69618"></rm_property:_6m0UhJUTEeGjDYB2VGA7DA>
The following is the property definition received from the Artifact Shape which I used for the formation of the above line. (for reference)
<oslc:property> <oslc:Property> <oslc:valueType rdf:resource="http://open-services.net/ns/core#Resource"/> <oslc:allowedValues> <oslc:AllowedValues> <oslc:allowedValue rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA#85f26fb6-2f9c-40db-83ff-aefe1ab69618"/> <oslc:allowedValue rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA#7dae3116-c257-4d97-88bd-a34f8f198d7c"/> <oslc:allowedValue rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA#8d078228-b25f-4609-8884-b0d38e0aa6ab"/> </oslc:AllowedValues> </oslc:allowedValues> <oslc:propertyDefinition rdf:resource="https://research.jazz:9443/rm/types/_6m0UhJUTEeGjDYB2VGA7DA"/> <oslc:range rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA"/> <oslc:defaultValue rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA#8d078228-b25f-4609-8884-b0d38e0aa6ab"/> <oslc:occurs rdf:resource="http://open-services.net/ns/core#Zero-or-one"/> <dc:description rdf:parseType="Literal"/> <oslc:name>Priority</oslc:name> </oslc:Property>
Cheers..!!
Comments
Hi there
I am currently having the same issue as mentioned in this post, when I do a get on the
url for property definition of an attribute , I get the values for the attributes and I am not getting the RDF data equivalent of 0 or 1 values.
I tried doing a get on the "https://localhost/rm/types/_9VwXzUNVEeGavIlLsxV1tA" which is the oslc:range rdf:resource. I get the following response:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:oslc_rm="http://open-services.net/ns/rm#">
</rdf:RDF>
So I was wondering how did you manage to get the RDF data for the values. Is tehre any specific changes you put as far as access control is considered.
Comments
Arun Batra
Jun 06 '12, 3:21 a.m.In Short, How to update a custom attribute using RRC Rest API?
Any possible solutions are welcome as it has become a blocker for us...
Thanks, Arun