Page 1 of 2

Custom Route Not Working Getting 404 Error

PostPosted: Sat Aug 06, 2022 6:49 am
by symimake
I have a custom route with help of example plugin for custom routes. I added a Rest Api plugin and I am not getting any error while compiling the plugin.

This my CustomServices class where I added one custom Route.
Code: Select all
#region Service
public class CustomServices : Service
{
    [Authenticate]
    public string POST(TestRequest request)
    {
        return request.Name;
    }
}
#endregion


Here I am registering the route and the service
Code: Select all
#region Registry
public class RESTAPIPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaRESTAPIPlugin
{
    public void Configure(JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin, ServiceStack.ServiceStackHost AppHost, Funq.Container Container, JiwaFinancials.Jiwa.JiwaApplication.Manager JiwaApplicationManager)
    {
        AppHost.RegisterService<CustomServices>();
        AppHost.Routes.Add(typeof(TestRequest), "/TestApi/TestEndpoint", "POST", "demo test endpoint", "");
    }
}
#endregion


This the request Object
Code: Select all
#region request

[Serializable()]
[ApiResponse(200, "Contacts read OK")]
[ApiResponse(401, "Not authenticated")]
[ApiResponse(404, "Not found")]
public class TestRequest : IReturn<string>
{
    public int Id { get; set; }
    public string Name { get; set; }
}
#endregion


Seems all steps are fine. What I missed here? Why I am getting 404 error?

I am using postman for testing the route.

My route URL looks like
http://localhost:8080/TestApi/TestEndpo ... AkFkasdfAK

Re: Custom Route Not Working Getting 404 Error

PostPosted: Sat Aug 06, 2022 2:36 pm
by Mike.Sheen
My first guess is you :

forgot to enable the plugin.
- or -
forgot to change the verb to POST instead of GET in Postman.

so, #1 : Is your plugin enabled? (top right of plugin maintenance form).

symimake_test_Enabled.png


and #2 : Did you perform a POST in Postman?

symimake_test_Postman_post.png


You should also check to see if your plugin is actually loaded by the API. Do this by visiting the /queries/startuplog route - you should see your plugin in there.

symimake_test_startuplog.png


If you don't see your plugin in there, then either it was not enabled or it encountered an error. You can see if there were errors by visiting /queries/pluginexceptions and also by looking at the Windows EventLog.

I created a new plugin, copy-pasted your code and tested using Postman and it worked fine - my plugin is attached - try with that to see if that works for you.

symimake_test_Postman.png

Re: Custom Route Not Working Getting 404 Error

PostPosted: Sat Aug 06, 2022 5:32 pm
by symimake
Hi Mike,

I rechecked all the steps and all are okay.

plugin.png
The plugin is enabled


psotman.png
Request type is correct


servicestack.png
Also visible on servicestack

Re: Custom Route Not Working Getting 404 Error

PostPosted: Sat Aug 06, 2022 5:36 pm
by Mike.Sheen
I provided you a plugin known to work - is there any reason why you didn't try that plugin?

Also, did you check the event log for any errors?

Re: Custom Route Not Working Getting 404 Error

PostPosted: Sat Aug 06, 2022 5:38 pm
by symimake
The test plguin that you attached is also not working for me. I tried restart the Rest APi service. Rebooted my pc but still having the same issue.

Re: Custom Route Not Working Getting 404 Error

PostPosted: Sat Aug 06, 2022 5:41 pm
by symimake
On which path jiwa creates log ?

Re: Custom Route Not Working Getting 404 Error

PostPosted: Sat Aug 06, 2022 5:41 pm
by Mike.Sheen
symimake wrote:The test plguin that you attached is also not working for me. I tried restart the Rest APi service. Rebooted my pc but still having the same issue.


Try checking the event log, I still think your plugin is not loading or compiling properly.

Might as well check /queries/pluginexceptions as well.

You should also disclose what version of Jiwa you have installed, and what the version of the REST API plugin is.

Re: Custom Route Not Working Getting 404 Error

PostPosted: Sat Aug 06, 2022 5:41 pm
by Mike.Sheen
symimake wrote:On which path jiwa creates log ?


It's the Windows Event log.

Re: Custom Route Not Working Getting 404 Error

PostPosted: Sat Aug 06, 2022 5:43 pm
by Mike.Sheen
This thing

EventLog.png

Re: Custom Route Not Working Getting 404 Error

PostPosted: Sat Aug 06, 2022 6:21 pm
by symimake
Thanks. Issue is resolved. First I closed the Jiwa and stop all its services then again restarted my PC and then its worked.

Thanks once again for your help.