It's all about the answers!

Ask a question

Asset creation fails while using OSLC RAM API AssetFactory


Kangkan Goswami (1571621) | asked Jun 15 '12, 2:10 a.m.
edited Jun 28 '12, 6:32 a.m.
I tried creating an asset inside a community (I am the admin of the community) as documented in https://jazz.net/wiki/bin/view/Main/RamV2RestApiMain

What I posted is same as shown in the document

URI:
http://server:port/ram/oslc/communityAssetFactory/1040?startTransaction=true
Headers:
Oslc-Core-Version: 2.0
Content-type: application/rdf+xml
Accept: application/rdf+xml
Body:
<pre>

&lt;rdf:RDF xmlns:dcterms=&quot;http://purl.org/dc/terms/&quot; xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:oslc_acc=&quot;http://open-services.net/ns/access#&quot; xmlns:ram_asset=&quot;http://jazz.net/xmlns/prod/ram/2.0/&quot; xmlns:oslc=&quot;http://open-services.net/ns/core#&quot; xmlns:oslc_asset=&quot;http://open-services.net/ns/asset#&quot;&gt;
    &lt;rdf:Description rdf:about=&quot;http://server:port/ram/oslc/assets/7034E08C-9C42-47C3-B6A5-4187786891CF/1.0&quot;&gt;
        &lt;dcterms:title&gt;Sample TFS Asset&lt;/dcterms:title&gt;
        &lt;oslc_asset:version&gt;1.0&lt;/oslc_asset:version&gt;
        &lt;ram_asset:community rdf:resource=&quot;http://server:port/ram/internal/communities/1040&quot; /&gt;
        &lt;rdf:type rdf:resource=&quot;http://open-services.net/ns/asset#Asset&quot; /&gt;
        &lt;oslc_asset:guid&gt;7034E08C-9C42-47C3-B6A5-4187786891CF&lt;/oslc_asset:guid&gt;
        &lt;dcterms:description&gt;Sample TFS Asset from REST Client&lt;/dcterms:description&gt;
        &lt;dcterms:type rdf:resource=&quot;internal/types/classif/assetTypesSchema.xmi%23tfs_artefact/communities/1040&quot; /&gt;
        &lt;oslc:instanceShape rdf:resource=&quot;internal/types/classif/assetTypesSchema.xmi%23tfs_artefact/communities/1040&quot; /&gt;
        &lt;dcterms:abstract&gt;New Entry&lt;/dcterms:abstract&gt;
    &lt;/rdf:Description&gt;
&lt;/rdf:RDF&gt;

</pre>

But on the first query, I get Error 500.

The error details is as follws:
Response header:
Date: Thu, 28 Jun 2012 05:40:46 GMT
Connection
: Close
Content-Length
: 17262
Server
: WebSphere Application Server/7.0
Pragma
: no-cache
max-age
: 0
Vary
: Accept accept-language accept-charset
Content-Language
: en-US 
Cache-Control: no-cache 
Content-Type: text/xml;charset=UTF-8 
Expires: Thu, 01 Jan 1970 00:00:00 GMT 

Part of the Response body (RAW):

<pre>

<oslc:statusCode>
500
</oslc:statusCode>
<oslc:message>
Error parsing the uploaded asset : unexpected element (uri:"http://www.w3.org/1999/02/22-rdf-syntax-ns#", local:"RDF"). Expected elements are <{http://open-services.net/xmlns/approval/1.0/}ApprovalQuery>,<{http://open-services.net/xmlns/approval/1.0/}ApprovalQueryResult>,<{http://open-services.net/xmlns/approval/1.0/}ApproverQuery>,<{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Description>,<{http://open-services.net/xmlns/asset/1.0/}ServiceDescriptor>,<{http://open-services.net/xmlns/discovery/1.0/}ServiceProviderCatalog>,<{http://purl.org/dc/terms/}abstract>,<{http://purl.org/dc/terms/}accessRights>,<{http://purl.org/dc/terms/}accrualMethod>,<{http://purl.org/dc/terms/}accrualPeriodicity>,<{http://purl.org/dc/terms/}accrualPolicy>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}action>,<{http://purl.org/dc/terms/}alternative>,<{http://purl.org/dc/elements/1.1/}any>,<{http://purl.org/dc/terms/}any>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}artifact>,<{http://open-services.net/xmlns/asset/1.0/}artifact>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}asset>,<{http://open-services.net/xmlns/asset/1.0/}asset>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}assetAttribute>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}assetType>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}attachment>,<{http://purl.org/dc/terms/}audience>,<{http://purl.org/dc/terms/}available>,<{http://purl.org/dc/terms/}bibliographicCitation>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}category>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}categorySchema>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}comment>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}community>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}communityAssetType>,<{http://jazz.net/xmlns/prod/jazz/presentation/1.0/}compactRendering>,<{http://purl.org/dc/terms/}conformsTo>,<{http://purl.org/dc/elements/1.1/}contributor>,<{http://purl.org/dc/terms/}contributor>,<{http://purl.org/dc/elements/1.1/}coverage>,<{http://purl.org/dc/terms/}coverage>,<{http://purl.org/dc/terms/}created>,<{http://purl.org/dc/elements/1.1/}creator>,<{http://purl.org/dc/terms/}creator>,<{http://purl.org/dc/elements/1.1/}date>,<{http://purl.org/dc/terms/}date>,<{http://purl.org/dc/terms/}dateAccepted>,<{http://purl.org/dc/terms/}dateCopyrighted>,<{http://purl.org/dc/terms/}dateSubmitted>,<{http://purl.org/dc/elements/1.1/}description>,<{http://purl.org/dc/terms/}description>,<{http://purl.org/dc/terms/}educationLevel>,<{http://www.w3.org/2005/Atom}entry>,<{http://open-services.net/ns/oslc}error>,<{http://purl.org/dc/terms/}extent>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}facet>,<{http://www.w3.org/2005/Atom}feed>,<{http://purl.org/dc/elements/1.1/}format>,<{http://purl.org/dc/terms/}format>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}forum>,<{http://purl.org/dc/terms/}hasFormat>,<{http://purl.org/dc/terms/}hasPart>,<{http://purl.org/dc/terms/}hasVersion>,<{http://www.omg.org/ras/v2.2}id>,<{http://purl.org/dc/elements/1.1/}identifier>,<{http://purl.org/dc/terms/}identifier>,<{http://purl.org/dc/terms/}instructionalMethod>,<{http://purl.org/dc/terms/}isFormatOf>,<{http://purl.org/dc/terms/}isPartOf>,<{http://purl.org/dc/terms/}isReferencedBy>,<{http://purl.org/dc/terms/}isReplacedBy>,<{http://purl.org/dc/terms/}isRequiredBy>,<{http://purl.org/dc/terms/}isVersionOf>,<{http://purl.org/dc/terms/}issued>,<{http://purl.org/dc/elements/1.1/}language>,<{http://purl.org/dc/terms/}language>,<{http://purl.org/dc/terms/}license>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}lifecyle>,<{http://purl.org/dc/terms/}mediator>,<{http://purl.org/dc/terms/}medium>,<{http://purl.org/dc/terms/}modified>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}permissions>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}policy>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}policyConfiguration>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}policyGovernor>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}post>,<{http://jazz.net/xmlns/prod/jazz/presentation/1.0/}preview>,<{http://purl.org/dc/terms/}provenance>,<{http://purl.org/dc/elements/1.1/}publisher>,<{http://purl.org/dc/terms/}publisher>,<{http://purl.org/dc/terms/}references>,<{http://purl.org/dc/elements/1.1/}relation>,<{http://purl.org/dc/terms/}relation>,<{http://purl.org/dc/terms/}replaces>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}repository>,<{http://purl.org/dc/terms/}requires>,<{http://purl.org/dc/elements/1.1/}rights>,<{http://purl.org/dc/terms/}rights>,<{http://purl.org/dc/terms/}rightsHolder>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}searchEntry>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}searchResult>,<{http://purl.org/dc/elements/1.1/}source>,<{http://purl.org/dc/terms/}source>,<{http://purl.org/dc/terms/}spatial>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}state>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}stateConfiguration>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}stateHistory>,<{http://purl.org/dc/elements/1.1/}subject>,<{http://purl.org/dc/terms/}subject>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}subscription>,<{http://purl.org/dc/terms/}tableOfContents>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}tag>,<{http://purl.org/dc/terms/}temporal>,<{http://purl.org/dc/elements/1.1/}title>,<{http://purl.org/dc/terms/}title>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}topic>,<{http://purl.org/dc/elements/1.1/}type>,<{http://purl.org/dc/terms/}type>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}user>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}userGroup>,<{http://purl.org/dc/terms/}valid>,<{http://jazz.net/xmlns/ecalm/ram/internal/v7.2}workflow>
</oslc:message>
</pre>
</pre>

Where Am I going wrong here?

Comments
Rich Kulp commented Jun 28 '12, 5:19 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

Are you actually putting semicolons in the xml? Your example shows semicolons (;) and they are not valid in xml where they are shown.


Kangkan Goswami commented Jun 29 '12, 12:46 a.m.

Nope! Those are the grace of the forum software!


Kangkan Goswami commented Jun 29 '12, 12:47 a.m.

Nope! Those are the grace of the forum software. The XML is validated using a validator as well. But I am missing something. The error says, there is some element which is not valid.

3 answers



permanent link
Sheehan Anderson (1.2k4) | answered Jul 01 '12, 6:29 p.m.
JAZZ DEVELOPER
edited May 18 '22, 11:06 a.m. by Shailee Sinha (113)

Here's a simple example to create a new asset.  You don't need to include information like the GUID as that will be generated when the asset is created.

POST
URI: http://localhost:8080/ram/oslc/assets/
Headers:
Oslc-Core-Version: 2.0
Content-type: application/rdf+xml
Accept: application/rdf+xml

Body:

Hope that helps.


Comments
Kangkan Goswami commented Jul 02 '12, 1:10 a.m.

I tried a lot of combinations. Finally, I used the format from the RAM REST API documentation version 1, and it worked for me.


permanent link
Gili Mendel (1.8k56) | answered Jun 15 '12, 1:37 p.m.
JAZZ DEVELOPER
edited Jun 15 '12, 5:57 p.m.
On you post above you have the following that does not looks like xml+rdf

...
<code>
 <dc:type <a="" href="rdf:resource=" internal="" types="" classif="" assetTypesSchema.xmi%23webservice"=""
</code>


....

Comments
Kangkan Goswami commented Jun 17 '12, 9:48 a.m.

Sorry @GiliMendel. It seems to be an error with the PRE tag in this new forum.


permanent link
Rich Kulp (3.6k38) | answered Jun 15 '12, 10:38 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
First, to make sure this trace you shown is not from a query (a get) but is the result of your original post?

If that is the case it looks like your post is being understood on the host as the data being in json format instead of xml format.

Please make sure that when you do the post that your post doesn't have one of these:

a) a header:  Content-Type: json
b) a header: Accept: json    <- where json is ahead or a has a higher priority than xml.

The best is to make sure that you tell the post that you are sending xml. In that case you would use a header of

Content-Type: xml

Also use this Content-Type when doing a PUT of xml data.

And then when you are requesting data (through get) that you want returned in xml, make sure you have an

Accept: xml    <- where xml is ahead or has a higher priority.

At the time the specs were written up that you were looking at it was only XML.

Rich


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

@RichardKulp: Thanks for your reply. I have just updated my post to include the header details. I added three headers: Oslc-Core-Version: 2.0, Content-type: application/rdf+xml, Accept: application/rdf+xml. Is there something that I missed? I too saw the error that was trying to get it as json. I could not create the body in json at this moment to try that out. Awaiting your further guidance.


Rich Kulp commented Jun 15 '12, 2:58 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

I'm not sure if you want 2.0 or 1.0. The code you were first showing me is OSLC 1.0. That is not 2.0. They are very different. If you are using the one you first showed then that 1.0 and you should then take off the Oslc version header and the content type should be just text/xml. 1.0 is not RDF.


Kangkan Goswami commented Jun 28 '12, 2:11 a.m.

@RichardKulp: I wish you could help me now. I have updated the post after reading through the updated API documentation. I am sure, I am missing something too small but very critical.

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.