Asset creation fails while using OSLC RAM API AssetFactory
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>
<rdf:RDF xmlns:dcterms="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:oslc_acc="http://open-services.net/ns/access#" xmlns:ram_asset="http://jazz.net/xmlns/prod/ram/2.0/" xmlns:oslc="http://open-services.net/ns/core#" xmlns:oslc_asset="http://open-services.net/ns/asset#">
<rdf:Description rdf:about="http://server:port/ram/oslc/assets/7034E08C-9C42-47C3-B6A5-4187786891CF/1.0">
<dcterms:title>Sample TFS Asset</dcterms:title>
<oslc_asset:version>1.0</oslc_asset:version>
<ram_asset:community rdf:resource="http://server:port/ram/internal/communities/1040" />
<rdf:type rdf:resource="http://open-services.net/ns/asset#Asset" />
<oslc_asset:guid>7034E08C-9C42-47C3-B6A5-4187786891CF</oslc_asset:guid>
<dcterms:description>Sample TFS Asset from REST Client</dcterms:description>
<dcterms:type rdf:resource="internal/types/classif/assetTypesSchema.xmi%23tfs_artefact/communities/1040" />
<oslc:instanceShape rdf:resource="internal/types/classif/assetTypesSchema.xmi%23tfs_artefact/communities/1040" />
<dcterms:abstract>New Entry</dcterms:abstract>
</rdf:Description>
</rdf:RDF>
</pre>
But on the first query, I get Error 500.
The error details is as follws:
Response header:
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
Part of the Response body (RAW):
<pre>
</pre></pre>
Where Am I going wrong here?
3 answers
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
@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.
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.
@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.
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
Rich Kulp
FORUM MODERATOR / JAZZ DEVELOPER 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
Jun 29 '12, 12:46 a.m.Nope! Those are the grace of the forum software!
Kangkan Goswami
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.