It's all about the answers!

Ask a question

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


Arun Batra (14612427) | asked May 31 '12, 7:48 a.m.
edited Jun 06 '12, 3:29 a.m.
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?

Comments
Arun Batra commented 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

8 answers



permanent link
Gabriel Ruelas (1.1k13) | answered Jul 18 '12, 10:24 a.m.
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.



Comments
1
Rosa Naranjo commented Jul 18 '12, 2:08 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

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?


permanent link
Gabriel Ruelas (1.1k13) | answered Jul 18 '12, 2:30 p.m.
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.

permanent link
Kangkan Goswami (15711621) | answered Jun 06 '12, 10:40 a.m.
edited Jun 06 '12, 10:42 a.m.
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.

Comments
Arun Batra commented Jun 07 '12, 1:38 a.m.

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


Kangkan Goswami commented Jun 07 '12, 2:17 a.m.

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
Arun Batra (14612427) | answered Jun 08 '12, 2:52 a.m.
edited Jun 08 '12, 2:53 a.m.
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

Comments
Kangkan Goswami commented Jun 08 '12, 3:08 a.m. | edited Jun 08 '12, 3:09 a.m.

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


Arun Batra commented Jun 08 '12, 3:12 a.m.

Ya sorry, the size was to big for the comment. I will keep the edit option in mind though. Thank You.


permanent link
Kangkan Goswami (15711621) | answered Jun 08 '12, 3:07 a.m.
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

Comments
Arun Batra commented Jun 08 '12, 3:19 a.m.

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.


Arun Batra commented Jun 08 '12, 3:19 a.m.

What can we try now?


Arun Batra commented Jun 11 '12, 7:13 a.m.

Hi Kangkan, This has become a major blocker for us. We would be grateful for any help we can get.


1
Kangkan Goswami commented Jun 11 '12, 7:15 a.m.

Still trying to work on it....


Arun Batra commented Jun 20 '12, 2:14 a.m.

Possibility for any solution?


permanent link
Arun Batra (14612427) | answered Jul 20 '12, 9:58 a.m.
edited Jul 20 '12, 10:00 a.m.
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..!!

Comments
Meera Varma commented Dec 07 '12, 7:46 a.m.

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
Amy Lai (1) | answered Oct 17 '12, 8:34 p.m.
By using the OSLC workshop, is there a limit of how many requirements can be created in RRC using the REST API?

permanent link
Gabriel Ruelas (1.1k13) | answered Oct 17 '12, 9:42 p.m.
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 )

Comments
Amy Lai commented Oct 22 '12, 9:22 p.m.

Hi Gabriel,

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

Amy

Your answer


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