Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Unable to upload an artifact using REST API

I'm trying to add a new artifact to an existent asset by calling the REST API.

The URL I use for the POST request is:
https://<server_IP>:9446/ram.ws/internal/assets/AAAAA-BBBBB-CCCCC-DDDDD/1.0
I add the following headers to the POST request:
Content-Type: application/java-archive   (I tried many other combinations)
oslc_asset.name: TestProject.zip (This is the name that should appear in the asset)

The binary file is attached to the body as "application/zip" content.

When I run the POST command I get the following error:
...
  <oslc:statusCode>500</oslc:statusCode>
    <oslc:message>Error POSTing asset null : Failed parsing JSON source: java.io.StringReader@62816281 to Json</oslc:message>
    <ram:trace>
        <ram:className>com.ibm.ram.repository.rest.RestAssetsService</ram:className>
        <ram:fileName>doPost</ram:fileName>
        <ram:lineNumber>1125</ram:lineNumber>
        <ram:methodName>RestAssetsService.java</ram:methodName>
        <ram:nativeMethod>false</ram:nativeMethod>
    </ram:trace>
....
Any idea about what can I do wrong? I don't understand why it tries to interpret the content as Json...

Thank you

0 votes

Comments

Version of RAM?


Accepted answer

Permanent link
By the way, that is not how you post an artifact. That is posting an asset, which by default is json.

Remember this is internal API. You should be using the OSLC REST calls. Those are supported. See http://pic.dhe.ibm.com/infocenter/ramhelp/v7r5m1/index.jsp?topic=%2Fcom.ibm.ram.doc%2Ftopics%2Fc_rest_api.html

(Sorry, wrong link first time around).
Iulian Stoica selected this answer as the correct answer

1 vote


2 other answers

Permanent link
RAM version is 7.5.1.

I changed the URL as it is specified in the document:
https://<RAM Server IP>:9446/ram.ws/RAMSecure/oslc/assets/AAAAA-BBBBB-CCCCC-DDDDD/1.0

but the result of the PUT or POST requests is pretty similar:
   <oslc:statusCode>500</oslc:statusCode>
    <oslc:message>Error PUTing asset Test Iulian[internal/assets/AAAAA-BBBBB-CCCCC-DDDDD/1.0] : Failed parsing JSON source: java.io.StringReader@6b076b07 to Json</oslc:message>
    <ram:trace>
        <ram:className>com.ibm.ram.repository.rest.RestOSLCAssetsService</ram:className>
        <ram:fileName>doPut</ram:fileName>
        <ram:lineNumber>681</ram:lineNumber>
        <ram:methodName>RestOSLCAssetsService.java</ram:methodName>
        <ram:nativeMethod>false</ram:nativeMethod>
    </ram:trace>

0 votes


Permanent link
Finally it worked!

I didn't pay attention to the URL syntax, I was focused on the attachment, my fault :-(

The right URL should be:

https://<server IP>:<port>/ram.ws/RAMSecure/oslc/assets/AAAAA-BBBBB-CCCCC-DDDDD/1.0/artifacts

Thanks Rich!

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 137

Question asked: Aug 12 '13, 11:48 a.m.

Question was seen: 5,238 times

Last updated: Aug 13 '13, 11:13 a.m.

Confirmation Cancel Confirm