AnsweredAssumed Answered

Unexpected error when uploading files via REST API

Question asked by rgomez_twx on May 5, 2017

I'm creating a piece of code on my php client to upload documents into Alfresco 5.2, via REST API.This is the code used to upload the content into Alfresco:
<?php

$json= ('
{
"filedata": "test2.txt",
"siteid": "SITE1",
"containerid": "documentLibrary",
"uploaddirectory": "/dir1",
"fileName": "test2.txt"
}
');

$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, "http://xxxxxx/alfresco/service/api/upload");
curl_setopt($curl_request, CURLOPT_POST, true);
curl_setopt($curl_request, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl_request, CURLOPT_POSTFIELDS, json_encode($json));
curl_setopt($curl_request, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl_request, CURLOPT_USERPWD,"user_pass");
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-type:text/json"));
$return = curl_exec($curl_request);

echo "<pre>";
print_r($return);
curl_close($curl_request);

?>

 

But, I'm getting the next error, and can't find where the error is. Any ideas?

 

2017-05-04 17:48:11,696 ERROR [org.springframework.extensions.webscripts.AbstractRuntime] [http-apr-8080-exec-508] Exception from executeScript: 04040455 Unexpected error occurred during upload of new content.
org.springframework.extensions.webscripts.WebScriptException: 04040455 Unexpected error occurred during upload of new content.
at org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1124)
at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:171)
at org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:519)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:464)
at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:587)
at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:656)
at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:428)
at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:308)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:399)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:210)
at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.alfresco.module.aosmodule.service.ContextRootFilter.doFilter(ContextRootFilter.java:93)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:68)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:2403)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.mozilla.javascript.JavaScriptException: ReferenceError: Unexpected error occurred during upload of new content. (classpath*:alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js#476)
at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_repository_upload_upload_post_js_25._c_main_4(classpath*:alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js:476)
at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_repository_upload_upload_post_js_25.call(classpath*:alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js)
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:74)
at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_repository_upload_upload_post_js_25._c_script_0(classpath*:alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js:480)
at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_repository_upload_upload_post_js_25.call(classpath*:alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_repository_upload_upload_post_js_25.call(classpath*:alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js)
at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_repository_upload_upload_post_js_25.exec(classpath*:alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js)
at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:509)
at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:207)
at org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:219)
at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:181)
at org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:109)
at org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1376)
at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
... 36 more

Thanks all for your comments!

Outcomes