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
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
Accepted answer
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).
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).
2 other answers
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>
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>
Comments
Rich Kulp
FORUM MODERATOR / JAZZ DEVELOPER Aug 12 '13, 12:47 p.m.Version of RAM?