It's all about the answers!

Ask a question

How should i extract the title of the moduleContent of requirments using REST API


chathurika brahmana (11) | asked Sep 17, 5:39 p.m.

 When I call this: https://localhost:9443/rm/publish/resources?resourceURI=-I4ezTYYEeqPqJ6cXaaMqA for highlighted resource, i get only a partial text content, i.e., text content is cropped after some level. 

"""
<ds:moduleContext>
<rrm:contextBinding>
<rrm:about>
https://localhost:9443/rm/resources/-I4ezTYYEeqPqJ6cXaaMqA
</rrm:about>
<rrm:identifier>27</rrm:identifier>
<rrm:title>
Second testing change. Im making a change for testing. This use case starts when the actor does something. An actor always initiates use cases. The use case describes what the actor does and what the system does in response. It is phrased in the form of a 
"""

But the title content should be this: 
"""
Second testing change. Im making a change for testing. This use case starts when the actor does something.  An actor always initiates use cases.  The use case describes what the actor does and what the system does in response. It is phrased in the form of a dialog between the actor and the system.
"""
How should i change my query (https://localhost:9443/rm/publish/resources?resourceURI=_-I4ezTYYEeqPqJ6cXaaMqA) to get the full text content of the tile?

One answer



permanent link
Subramanya Prasad Pilar (3.9k14) | answered Sep 18, 1:06 a.m.
edited Sep 18, 1:09 a.m.

This is expected. dataSource/artifact/moduleContext/contextBinding/title returns only first 256 characters. To print the requirement completely (with formatting), you must use "text" artifact type (that is, do a GET request on https://localhost:9443/rm/publish/text?resourceURI=-I4ezTYYEeqPqJ6cXaaMqA) and use dataSource/artifact/content/text/richTextBody/div. You see the length limitation when you print dataSource/artifact/title (for resources or text artifact) as well.


Comments
chathurika brahmana commented Sep 18, 12:47 p.m.

Thank you so much. I'm net to Jazz and REST API. I wonder whether you can explain bit more. 

As you said, I requested "text" artifact by  and saved the content in to a .xml.  but it has so much details in it. 
{
tree = ET.ElementTree(ET.fromstring(response.text))
tree.write('../data/xml_files/temp1.xml')
}

Can you explain what you mean by " use dataSource/artifact/content/text/richTextBody/div" ? I want to extract clean text content. 



Subramanya Prasad Pilar commented Sep 18, 12:59 p.m.
By dataSource/artifact/content/text/richTextBody/div I meant the XPath in the XML data. Since you can edit the requirement text in rich text editor, you will get the formatting along with the text.
If you want plain text, you can append ptext=true to the request URL (ex.
https://localhost:9443/rm/publish/text?resourceURI=_-I4ezTYYEeqPqJ6cXaaMqA&ptext=true or
https://localhost:9443/rm/publish/resources?resourceURI=_-I4ezTYYEeqPqJ6cXaaMqA&ptext=true) and use dataSource/artifact/primaryText

chathurika brahmana commented Sep 18, 1:35 p.m.

Hmmm.... I think I did explain what i wanted in a wrong way. I want to take the text within <rrm:title> .....tex tex text </rrm:title> 


<ds:moduleContext>
<rrm:contextBinding>
<rrm:about>
</rrm:about>
<rrm:identifier>27</rrm:identifier>
<rrm:title>
Second testing change. Im making a change for testing. This use case starts when the actor does something. An actor always initiates use cases. The use case describes what the actor does and what the system does in response. It is phrased in the form of a <<missing text>>
</rrm:title>

I apologies for asking again. Thank you.


Subramanya Prasad Pilar commented Sep 19, 1:39 p.m.

For title attribute, the maximum number of characters is limited to 256.


chathurika brahmana commented Sep 21, 1:03 p.m.

Thank you for letting me know. I'll check whether there is any other way to get full title data using Rest API

Your answer


Register or to post your answer.