cancel
Showing results for 
Search instead for 
Did you mean: 

Error with REST request (site memberships)

hferreira
Champ in-the-making
Champ in-the-making
I have created a public site in alfresco and I am trying to add members through the REST API. Bu the request I'm using is throwing an HTTP 500 error code. Here is the path I'm using:
@PUT /alfresco/service/api/sites/mysite/memberships
{"person":{"userName":"daniel"},"role":"SiteCollaborator"}

And this is the error message:
 
{ "status" : { "code" : 500, "name" : "Internal Error", "description" : "An error inside the HTTP server which prevented it from fulfilling the request." }, "message" : "00280029 Wrapped Exception (with status template): 00280076 Error during processing of the template 'When calling macro \"membershipJSON\", required parameter \"role\" (parameter #2) was specified, but had null\/missing value.\n\nTip: If the parameter value expression on the caller side is known to be legally null\/missing, you may want to specify a default value for it with the \"!\" operator, like paramValue!defaultValue.\n\nThe failing instruction:\n==> @membershipLib.membershipJSON site=si… [in template \"org\/alfresco\/repository\/site\/membership\/memberships.post.json.ftl\" at line 2, column 1]'. Please contact your system administrator.", "exception" : "org.springframework.extensions.webscripts.WebScriptException - 00280029 Wrapped Exception (with status template): 00280076 Error during processing of the template 'When calling macro \"membershipJSON\", required parameter \"role\" (parameter #2) was specified, but had null\/missing value.\n\nTip: If the parameter value expression on the caller side is known to be legally null\/missing, you may want to specify a default value for it with the \"!\" operator, like paramValue!defaultValue.\n\nThe failing instruction:\n==> @membershipLib.membershipJSON site=si… [in template \"org\/alfresco\/repository\/site\/membership\/memberships.post.json.ftl\" at line 2, column 1]'. Please contact your system administrator.", "callstack" : [ "" ,"freemarker.core._MiscTemplateException: When calling macro \"membershipJSON\", required parameter \"role\" (parameter #2) was specified, but had null\/missing value.\n\nTip: If the parameter value expression on the caller side is known to be legally null\/missing, you may want to specify a default value for it with the \"!\" operator, like paramValue!defaultValue.\n\nThe failing instruction:\n==> @membershipLib.membershipJSON site=si… [in template \"org\/alfresco\/repository\/site\/membership\/memberships.post.json.ftl\" at line 2, column 1]" ,"freemarker.core.Macro$Context.sanityCheck(Macro.java:249)" ,"freemarker.core.Macro$Context.runMacro(Macro.java:206)" ,"freemarker.core.Environment.visit(Environment.java:694)" ,"freemarker.core.UnifiedCall.accept(UnifiedCall.java:116)" ,"freemarker.core.Environment.visit(Environment.java:265)" ,"freemarker.core.MixedContent.accept(MixedContent.java:93)" ,"freemarker.core.Environment.visit(Environment.java:265)" ,"freemarker.core.Environment.process(Environment.java:243)" ,"org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:218)" ,"org.springframework.extensions.webscripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:955)" ,"org.springframework.extensions.webscripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:267)" ,"org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)" ,"org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:433)" ,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:454)" ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:495)" ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:563)" ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:343)" ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378)" ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)" ,"org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)" ,"javax.servlet.http.HttpServlet.service(HttpServlet.java:727)" ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)" ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)" ,"org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)" ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)" ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)" ,"org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)" ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)" ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)" ,"org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)" ,"org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)" ,"org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)" ,"org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)" ,"org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)" ,"org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)" ,"org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)" ,"org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)" ,"org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)" ,"org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)" ,"org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)" ,"java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)" ,"java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)" ,"java.lang.Thread.run(Thread.java:745)" ,"org.alfresco.service.cmr.repository.TemplateException: 00280076 Error during processing of the template 'When calling macro \"membershipJSON\", required parameter \"role\" (parameter #2) was specified, but had null\/missing value.\n\nTip: If the parameter value expression on the caller side is known to be legally null\/missing, you may want to specify a default value for it with the \"!\" operator, like paramValue!defaultValue.\n\nThe failing instruction:\n==> @membershipLib.membershipJSON site=si… [in template \"org\/alfresco\/repository\/site\/membership\/memberships.post.json.ftl\" at line 2, column 1]'. Please contact your system administrator." ,"org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:222)" ,"org.springframework.extensions.webscripts.WebScriptException: 00280029 Wrapped Exception (with status template): 00280076 Error during processing of the template 'When calling macro \"membershipJSON\", required parameter \"role\" (parameter #2) was specified, but had null\/missing value.\n\nTip: If the parameter value expression on the caller side is known to be legally null\/missing, you may want to specify a default value for it with the \"!\" operator, like paramValue!defaultValue.\n\nThe failing instruction:\n==> @membershipLib.membershipJSON site=si… [in template \"org\/alfresco\/repository\/site\/membership\/memberships.post.json.ftl\" at line 2, column 1]'. Please contact your system administrator." ,"org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1126)" ], "server" : "Community v5.0.0 (r75118-b23) schema 8,001", "time" : "28-Jan-2015 10:24:58" }


What am I missing here? Is this a bad server configuration?
2 REPLIES 2

jpotts
World-Class Innovator
World-Class Innovator

It is critical when you do a PUT against this URL that you pass the content-type header with a value of "application/json". If you do not, you will see that error.

sujaypillai
Confirmed Champ
Confirmed Champ

Here is an example of how to do it through POSTMAN Rest Client

Adding a sitemeber with specific role

and as Jeff Potts‌ mentioned here are the 2 headers to be passed

Headers for sitemembership POST call