createRequirements Interface

The createRequirements interface is used to create new requirements. The HTTP response of the call contains the XML structure of the changed requirements. You can obtain the identifiers of the new nodes from the updated XML requirement structure.

The following table shows the parameters of the createRequirements interface.

Interface URL Parameter Descriptions

http://<front-end URL>/servicesExchange?hid=createRequirements

sid Web-service token or session identifier for user authentication. You can generate the web-service token in the Settings Page of the Silk Central UI. To access this page, hover the mouse cursor over the user name in the Silk Central menu and select User Settings. You can retrieve the session identifier by invoking the logonUser method of one of the Available Web Services.
  parentNodeID ID of the container to which the new requirement is added in the requirements tree

Example: http://<front-end URL>/servicesExchange?hid=createRequirements&parentNodeID=<id>&sid=<webServiceToken>

The XML schema definition file that is used to validate requirements can be downloaded by using the front-end server URL http://<front-end URL>/silkroot/xsl/requirements.xsd or copied from the front-end server installation folder <Silk Central installation folder>/wwwroot/silkroot/xsl/requirements.xsd.

createRequirements Web Service Example

The following code uses Apache HttpClient to create requirements.

import org.apache.commons.httpclient.*; // Apache HttpClient

String webServiceToken = "e39a0b5b-45db-42db-84b2-b85028d954d5";

URL service = new URL("http", mWebServiceHelper.getHost(),
  "createRequirements", webServiceToken,
HttpClient client = new HttpClient();
PostMethod filePost = new PostMethod(service.toExternalForm());
String xmlFile = loadRequirementsUtf8("requirements.xml");
StringPart xmlFileItem = new StringPart("requirements", xmlFile,
Part[] parts = {xmlFileItem};

filePost.setRequestEntity(new MultipartRequestEntity(parts,
int status = client.executeMethod(filePost);

Only one attachment can be uploaded per request. To download Apache HttpComponents, visit Refer to the documentation of the component for the required libraries.

Requirements Example

The following code shows an example requirement that can be uploaded to Silk Central by using the createRequirements, updateRequirements and updateRequirementsByExtID service.

<?xml version="1.0" encoding="UTF-8"?>
<Requirement id="0" name="name" xmlns="" 
	xsi:schemaLocation="http://<front-end URL>/silkroot/xsl/requirements.xsd">
	<Priority value="Low" inherited="false"/>
	<Risk value="Critical" inherited="false"/>
	<Reviewed value="true" inherited="false"/>
	<Property inherited="false" name="Document" type="string">MyDocument1.doc</Property>
	<Requirement id="1" name="name" />
	<Requirement id="2" name="name1">
		<Requirement id="3" name="name" />
		<Requirement id="4" name="name1">
			<Requirement id="5" name="name" />
      <Requirement id="6" name="name1">
        <Description>Another Description</Description>
        <Priority value="Medium" inherited="false"/>
        <Risk value="Critical" inherited="false"/>
        <Reviewed value="true" inherited="false"/>
        <Property inherited="false" name="Document" type="string">MyDocument2.doc</Property>