Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

POST/PUT Requirement with a Custom Attribute Using REST API / OSLC

Following the OSLC workshops, We have been able to create a new requirement in RRC using the REST API. The body used in the POST request is as below.

<?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 priority (property id = _6m0UhJUTEeGjDYB2VGA7DA) in this requirement and we would like to fill in its value as well.

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?

1 vote

Comments

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



8 answers

Permanent link
Hi,
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.


1 vote

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


Permanent link
Here is the sample output of a Get to the type of an attribute: "https://gradev.ibm.com:9444/rdm/accessControl/_OcYF0sSMEeGA8-GkKWmlAA"

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.

1 vote


Permanent link
If the attribute you are trying to PUT is described by the rm_property as you are describing

<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.

0 votes

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.


Permanent link
The above query gives me the artifact shape. In this shape, the artifact is described as follows

<oslc:Property>
<oslc:valueType rdf:resource="http://open-services.net/ns/core#Resource"/>
<oslc:propertyDefinition rdf:resource="https://research.jazz:9443/rm/types/_6m0UhJUTEeGjDYB2VGA7DA"/>
<oslc:range rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA"/>
<oslc:occurs rdf:resource="http://open-service.net/ns/core#Zero-or-one"/>
<dc:description rdf:parseType="Literal"/>
<oslc:name>Priority</oslc:name>
</oslc:Property>

Next i used GET on the propertyDefinition (https://research.jazz:9443/rm/types/_6m0UhJUTEeGjDYB2VGA7DA) and i received the following response

<rdf:RDF>
<oslc:Property>
<oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#int"/>
<oslc:allowedValues>
<oslc:AllowedValues>
<oslc:allowedValue rdf:datatype="http://www.w3.org/2001/XMLSchema#int">0</oslc:allowedValue>
<oslc:allowedValue rdf:datatype="http://www.w3.org/2001/XMLSchema#int">1</oslc:allowedValue>
<oslc:allowedValue rdf:datatype="http://www.w3.org/2001/XMLSchema#int">2</oslc:allowedValue>
</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:occurs rdf:resource="http://open-service.net/ns/core#Zero-or-one"/>
<dc:description rdf:parseType="Literal"/>
<oslc:name>Priority</oslc:name>
</oslc:Property>
</rdf:RDF>


I request you to assist on how to create the correct format.

Thank You,
Arun

0 votes

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.


Permanent link
So the allowed values are 0,1 and 2 and the data type is int. So, please try sending an int to that value within the range of 0.1.2. Something like this - 0

0 votes

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?


Permanent link
Thank You Gabriel for the great hint...

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..!!

0 votes

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.


Permanent link
By using the OSLC workshop, is there a limit of how many requirements can be created in RRC using the REST API?

0 votes


Permanent link
Hi,
The OSLC Requirement Creation factory allows users to create 1 requirement per request. But users can make any number of requests ( I have created thousands of requirements using the creation factory )

0 votes

Comments

Hi Gabriel,

Thankyou for getting back to me on my enquiry. Much Appreciated =)

Amy

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 516
× 479

Question asked: May 31 '12, 7:48 a.m.

Question was seen: 10,044 times

Last updated: Dec 07 '12, 7:46 a.m.

Confirmation Cancel Confirm