1
我有一個php腳本,它會向我的Alfresco的本地副本創建捲髮請求以創建文件夾。但是,答覆是'不好的請求'。下面是我的腳本,用於在戶外創建子文件夾的API
<?php
$url = 'http://admin:[email protected]:8080/alfresco/service/api/site/folder/mysite/documentLibrary';
$postfields = array(
"name"=> "abc",
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($postfields));
$return = curl_exec($curl);
curl_close($curl);
echo $return;
?>
我得到的迴應如下:
{
"status" :
{
"code" : 400,
"name" : "Bad Request",
"description" : "Request sent by the client was syntactically incorrect."
},
"message" : "11120011 Invalid JSON: null",
"exception" : "org.springframework.extensions.webscripts.WebScriptException - 11120011 Invalid JSON: null",
"callstack" :
[
"" ,"org.springframework.extensions.webscripts.WebScriptException: 11120011 Invalid JSON: null"
,"org.alfresco.repo.web.scripts.node.NodeFolderPost.executeImpl(NodeFolderPost.java:125)"
,"org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)"
,"org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:433)"
,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:433)"
,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:495)"
,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:533)"
,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:349)"
,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)"
,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)"
,"org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)"
,"javax.servlet.http.HttpServlet.service(HttpServlet.java:728)"
,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)"
,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)"
,"org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)"
,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)"
,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)"
,"org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)"
,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)"
,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)"
,"org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)"
,"org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)"
,"org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)"
,"org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)"
,"org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)"
,"org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)"
,"org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)"
,"org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)"
,"org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)"
,"org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)"
,"org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)"
,"java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)"
,"java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)"
,"java.lang.Thread.run(Thread.java:744)"
],
"server" : "Community v4.2.0 (4576) schema 6,022",
"time" : "Dec 12, 2013 12:45:10 PM"
}
我在做什麼錯?
Ehm可能你的JSON無效。因此,使用一個web-dev工具來查看請求和響應,以便您可以抓取請求JSON並將其發佈到此處。 –
我用httpbin.org請求取代了我的Alfresco URL,取得了巨大的成功。已保存的日子。 –