Hi Sameera, I was able to resolve the issue by following your suggestions.
Thanks and regards, Sathya *Sathya Bandara* Software Engineering Intern Email: [email protected] Mobile: +94 715 360 421 On Mon, Apr 4, 2016 at 12:29 PM, Sameera Medagammaddegedara < [email protected]> wrote: > Hi Sathya, > > The publisher-apis directory is already present in the > publisher/extensions/app directory.Thus your new extension may not be > loading. > > Please rename the extension and remove the following line from your app.js: > > app.dependencies=['publisher-common']; > > I have attached a sample app extension containing a "foo" API.Can you > please try accessing this API by making a request to /apis/foo . > > Thank You, > Sameera > > On Mon, Apr 4, 2016 at 11:59 AM, Sathya Bandara <[email protected]> wrote: > >> Hi, >> >> I'm in the process of creating an app extension to Process Center - >> Publisher in order to add a new API. I have created publisher-apis >> directory structure in extensions/app/ directory path. This is my app.js >> file where search.jag is the controller to serve the new API. >> >> app.dependencies=['publisher-common']; >> >> app.server = function(ctx) { >> return { >> endpoints: { >> apis: [{ >> url:'search', >> path:'search.jag', >> secured:true >> }] >> } >> } >> }; >> >> app.apiHandlers = function(ctx) { >> return { >> onApiLoad: function() { >> if ((ctx.isAnonContext) && (ctx.endpoint.secured)) { >> >> //ctx.res.status='401';//sendRedirect(ctx.appContext+'/login'); >> print('{ error:"Authentication error" }'); //TODO: Fix >> this to return a proper status code >> return false; >> } >> return true; >> } >> }; >> }; >> >> And this is my JS function from where the new endpoint is called. >> >> if($("#content").val()){ >> >> var search_url = caramel.tenantedUrl('/apis/search') ; >> $.ajax({ >> url: search_url, >> method: 'POST', >> data: 'search-query:'+ $("#content").val(), >> success:function(data){ >> if(data){ >> console.log("success"); >> } >> },error:function(xhr, status, error){ >> console.log(error); >> doPagination = false; >> $('.loading-animation-big').remove(); >> } >> }); >> } >> >> But it gives me the error: "Unable to locate a suitable endpoint for >> search". Any help would be highly appreciated. >> >> Thanks, >> Sathya >> >> >> *Sathya Bandara* >> Software Engineering Intern >> Email: [email protected] >> Mobile: +94 715 360 421 >> > > > > -- > Sameera Medagammaddegedara > Software Engineer > > Contact: > Email: [email protected] > Mobile: + 94 077 255 3005 >
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
