It's all about the answers!

Ask a question

Unable to upload an artifact using REST API


Iulian Stoica (613) | asked Aug 12 '13, 11:48 a.m.
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


Comments
Rich Kulp commented Aug 12 '13, 12:47 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

Version of RAM?

Accepted answer


permanent link
Rich Kulp (3.6k38) | answered Aug 12 '13, 12:52 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited Aug 13 '13, 10:56 a.m.
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

2 other answers



permanent link
Iulian Stoica (613) | answered Aug 13 '13, 4:14 a.m.
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>

permanent link
Iulian Stoica (613) | answered Aug 13 '13, 11:13 a.m.
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!

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.