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

What I posted is same as shown in the document

Oslc-Core-Version: 2.0
Content-type: application/rdf+xml
Accept: application/rdf+xml

&lt;rdf:RDF xmlns:dcterms=&quot;; xmlns:rdf=&quot;; xmlns:oslc_acc=&quot;; xmlns:ram_asset=&quot;; xmlns:oslc=&quot;; xmlns:oslc_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;ram_asset:community rdf:resource=&quot;http://server:port/ram/internal/communities/1040&quot; /&gt;
        &lt;rdf:type rdf:resource=&quot;; /&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;


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
: Close
: 17262
: WebSphere Application Server/7.0
: no-cache
: 0
: Accept accept-language accept-charset
: 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):


Error parsing the uploaded asset : unexpected element (uri:"", local:"RDF"). Expected elements are <{}ApprovalQuery>,<{}ApprovalQueryResult>,<{}ApproverQuery>,<{}Description>,<{}ServiceDescriptor>,<{}ServiceProviderCatalog>,<{}abstract>,<{}accessRights>,<{}accrualMethod>,<{}accrualPeriodicity>,<{}accrualPolicy>,<{}action>,<{}alternative>,<{}any>,<{}any>,<{}artifact>,<{}artifact>,<{}asset>,<{}asset>,<{}assetAttribute>,<{}assetType>,<{}attachment>,<{}audience>,<{}available>,<{}bibliographicCitation>,<{}category>,<{}categorySchema>,<{}comment>,<{}community>,<{}communityAssetType>,<{}compactRendering>,<{}conformsTo>,<{}contributor>,<{}contributor>,<{}coverage>,<{}coverage>,<{}created>,<{}creator>,<{}creator>,<{}date>,<{}date>,<{}dateAccepted>,<{}dateCopyrighted>,<{}dateSubmitted>,<{}description>,<{}description>,<{}educationLevel>,<{}entry>,<{}error>,<{}extent>,<{}facet>,<{}feed>,<{}format>,<{}format>,<{}forum>,<{}hasFormat>,<{}hasPart>,<{}hasVersion>,<{}id>,<{}identifier>,<{}identifier>,<{}instructionalMethod>,<{}isFormatOf>,<{}isPartOf>,<{}isReferencedBy>,<{}isReplacedBy>,<{}isRequiredBy>,<{}isVersionOf>,<{}issued>,<{}language>,<{}language>,<{}license>,<{}lifecyle>,<{}mediator>,<{}medium>,<{}modified>,<{}permissions>,<{}policy>,<{}policyConfiguration>,<{}policyGovernor>,<{}post>,<{}preview>,<{}provenance>,<{}publisher>,<{}publisher>,<{}references>,<{}relation>,<{}relation>,<{}replaces>,<{}repository>,<{}requires>,<{}rights>,<{}rights>,<{}rightsHolder>,<{}searchEntry>,<{}searchResult>,<{}source>,<{}source>,<{}spatial>,<{}state>,<{}stateConfiguration>,<{}stateHistory>,<{}subject>,<{}subject>,<{}subscription>,<{}tableOfContents>,<{}tag>,<{}temporal>,<{}title>,<{}title>,<{}topic>,<{}type>,<{}type>,<{}user>,<{}userGroup>,<{}valid>,<{}workflow>

Where Am I going wrong here?

Rich Kulp commented Jun 28 '12, 5:19 p.m.

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
Rich Kulp (3.6k38) | answered Jun 15 '12, 10:38 a.m.
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.


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.

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.

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

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


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
Sheehan Anderson (1.2k4) | answered Jul 01 '12, 6:29 p.m.
edited Jul 01 '12, 6:44 p.m.
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.

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


Link to text for copy/paste

Hope that helps.

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.

Your answer

Register or to post your answer.