I want to create custom rest api in alfresco.
How can i do that?
I have made following configuration.but it is not working.
<context:component-scan base-package="com.controller"></context:component-scan>
package com.tritex.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value = "/contract")
public class TestController {
@RequestMapping(value = "/test", method = RequestMethod.GET)
public String display() {
return "Hello World";
}
}
For developing rest api in alfresco you need to use webscript.
Below links will help you in how to develop a webscript.
https://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html
I know this way to create api but i want to create in spring way using annotation and is it working same way as webscript api?
I have used REST · dgradecak/alfresco-mvc Wiki · GitHub and it is working.
Do you have any idea about this?
Hi,
you can create your own custom REST API in Alfresco.
First take a look at this : GitHub - covolution/quick-api: Basic example of developing a Rest API on the Alfresco Platform that ...
Basically it's quite simple :
create java package in your repo project.
create EntityResource with CRUD actions and specify endpoint
annotate your package in a file "package-info.java"
add your package in your module-context.xml file
(<context:component-scan base-package="[put your java package here]"></context:component-scan>)
then go to :
Using webscripts and other aprocahes proposed in this thread are ok, but how come "@RestController" (initial question) does not work? I tried that myself and I see
Identified candidate component class: URL [jar:file:/usr/local/tomcat/webapps/alfresco/WEB-INF/lib/dms-test-platform-1.0-SNAPSHOT.jar!/dmstest/service/MyService.class
but the spring bean is not created and it is not mapped to a service endpoint. I am trying to figure that out, any hint will be helpfull.
Thanks!
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.