It's all about the answers!

Ask a question

How do I create a configuration in DNG via OSLC API


Arthur Kleer (303) | asked Mar 04 '22, 1:39 p.m.
edited Mar 04 '22, 1:41 p.m.

Hi,


I am trying to create configurations (streams, baselines, changesets) via the OSLC API.
I successfully can create components.

I implemented it according to:
(or at least I tried, not sure if the problem is on my side)

The steps

I am sending (POST) the following data
<rdf:RDF
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:ldp="http://www.w3.org/ns/ldp#"
    xmlns:oslc="http://open-services.net/ns/core#"
    xmlns:oslc_config="http://open-services.net/ns/config#"
    xmlns:acc="http://open-services.net/ns/core/acc#"
    xmlns:process="http://jazz.net/ns/process#">
    <oslc_config:Baseline>
        <dcterms:title rdf:parseType="Literal">Baseline new baseline via API</dcterms:title>
        <dcterms:subject rdf:parseType="Literal">Tag</dcterms:subject>
        <dcterms:description rdf:parseType="Literal">Description Baseline new baseline via API</dcterms:description>
        <oslc:shortTitle>Baseline</oslc:shortTitle>
    </oslc_config:Baseline>
</rdf:RDF>
to the following URI

this URI is read from the stream properties. A GET on this URI, pulls existing baselines. So it seems to be correct.

The Problem

The POST returns a 202, which I try to handle, by reading the URI in the Location header. This indicates that the configuration could not be created (and it is not). 

https://xyz-dng-server/taskTracker/15647728-61ce-46a9-8d1e-4a1391150dc0
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:jfs="http://jazz.net/xmlns/foundation/1.0/"
xmlns:acp="http://jazz.net/ns/acp#"
xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/"
xmlns:jazz_rm="http://jazz.net/ns/rm#"
xmlns:acc="http://open-services.net/ns/core/acc#"
xmlns:rmTypes="http://www.ibm.com/xmlns/rdm/types/"
xmlns:process="http://jazz.net/ns/process#"
xmlns:rmWorkflow="http://www.ibm.com/xmlns/rdm/workflow/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:h="http://www.w3.org/TR/REC-html40"
xmlns:xs="http://schema.w3.org/xs/"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:nav="http://jazz.net/ns/rm/navigation#"
xmlns:oslc_config="http://open-services.net/ns/config#"
xmlns:oslc_rm="http://open-services.net/ns/rm#"
xmlns:dng_task="http://jazz.net/ns/rm/dng/task#"
xmlns:rm="http://www.ibm.com/xmlns/rdm/rdf/"
xmlns:oslc_auto="http://open-services.net/ns/auto#">
<oslc_config:Activity rdf:about="https://xyz-dng-server/taskTracker/15647728-61ce-46a9-8d1e-4a1391150dc0">
<dcterms:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Create Child Configuration Task</dcterms:title>
<oslc_auto:state rdf:resource="http://open-services.net/ns/auto#complete"/>
<dcterms:references>
<oslc:Error>
<oslc:statusCode>0</oslc:statusCode>
<oslc:message>Unexpected exception while executing task</oslc:message>
</oslc:Error>
</dcterms:references>
<oslc_auto:verdict rdf:resource="http://open-services.net/ns/auto#error"/>
</oslc_config:Activity>
</rdf:RDF>

Any idea if I am doing something wrong here? Especially I am not sure about the data to be sent.
I used a similar structure as for the component creation, except the oslc_config:Baseline instead of the oslc_config:Component

Accepted answer


permanent link
Ian Barnard (1.8k613) | answered Mar 07 '22, 9:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Mar 08 '22, 4:18 a.m.

202 is the expected response - the Location header in the response is the TaskTracker, you have to poll this until it indicates completion. When it indicates completion, for a success the result is a URL of the new baseline, or for failure there might be some sort of error indication like you have.


When I've tried this the minimal content in the POST was:

<rdf:RDF
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:oslc_config="http://open-services.net/ns/config#">
      <oslc_config:Configuration rdf:about="https://jazz.ibm.com:9443/rm/cm/changeset/something">
        <dcterms:title rdf:parseType="Literal">Title of the Baseline</dcterms:title>
        <dcterms:description rdf:parseType="Literal">Some Description of Baseline</dcterms:description>      
        <oslc_config:component rdf:resource="https://jazz.ibm.com:9443/rm/cm/component/_4KRMENcKEeqXpuBdEolY7w"/>
      </oslc_config:Configuration>
</rdf:RDF>

So maybe try removing the tag and short title, and adding the oslc_config:component. The description is I believe optional as well. Most likely the real problem is the missing oslc_config:component.

HTH
Ian

Arthur Kleer selected this answer as the correct answer

Comments
Ralph Schoon commented Mar 07 '22, 9:54 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Arthur Kleer commented Mar 07 '22, 12:27 p.m.

Thanks,

the combination of adding oslc_config:component and the rdf:about in the oslc_config:Configuration (or oslc_config:Baseline, both work) did the trick.

One other answer



permanent link
Ralph Schoon (62.7k33643) | answered Mar 07 '22, 2:11 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 I have found https://jazz.net/forum/questions/249582/is-there-a-rest-api-for-dng-to-create-a-local-streamcomponent-and-baseline, maybe that helps. I used https://www.google.com/search?q=dng+create+stream+API+site%3Ajazz.net 


I ran into a strange issue when creating change sets with the API, where the POST caused a null pointer exception in the server, unless you sent a valid URI (rdf:about). Consider GETting a configuration and see if there are properties missing. 


Comments
Arthur Kleer commented Mar 07 '22, 12:32 p.m.

without rdf:about, neither Baseline, Stream nor Changeset work for me. the TaskTracker always responds with "Unexpected exception while executing task", same when omitting the oslc_config:component. Cannot tell if that also caused a null pointer on server side.


With about and component, it works perfectly!

Your answer


Register or to post your answer.