Custom Route Not Working Getting 404 Error  Topic is solved

Discussions relating to the REST API of Jiwa 7.

Custom Route Not Working Getting 404 Error

Postby symimake » Sat Aug 06, 2022 6:49 am

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
symimake
Occasional Contributor
Occasional Contributor
 
Posts: 16
Joined: Thu Jul 28, 2022 3:38 pm

Re: Custom Route Not Working Getting 404 Error

Postby Mike.Sheen » Sat Aug 06, 2022 2:36 pm

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
Attachments
Plugin symimake test.xml
(8.68 KiB) Downloaded 48 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Custom Route Not Working Getting 404 Error

Postby symimake » Sat Aug 06, 2022 5:32 pm

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
symimake
Occasional Contributor
Occasional Contributor
 
Posts: 16
Joined: Thu Jul 28, 2022 3:38 pm

Re: Custom Route Not Working Getting 404 Error

Postby Mike.Sheen » Sat Aug 06, 2022 5:36 pm

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?
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Custom Route Not Working Getting 404 Error

Postby symimake » Sat Aug 06, 2022 5:38 pm

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.
symimake
Occasional Contributor
Occasional Contributor
 
Posts: 16
Joined: Thu Jul 28, 2022 3:38 pm

Re: Custom Route Not Working Getting 404 Error

Postby symimake » Sat Aug 06, 2022 5:41 pm

On which path jiwa creates log ?
symimake
Occasional Contributor
Occasional Contributor
 
Posts: 16
Joined: Thu Jul 28, 2022 3:38 pm

Re: Custom Route Not Working Getting 404 Error

Postby Mike.Sheen » Sat Aug 06, 2022 5:41 pm

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.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Custom Route Not Working Getting 404 Error

Postby Mike.Sheen » Sat Aug 06, 2022 5:41 pm

symimake wrote:On which path jiwa creates log ?


It's the Windows Event log.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Custom Route Not Working Getting 404 Error

Postby Mike.Sheen » Sat Aug 06, 2022 5:43 pm

This thing

EventLog.png
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Custom Route Not Working Getting 404 Error

Postby symimake » Sat Aug 06, 2022 6:21 pm

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.
symimake
Occasional Contributor
Occasional Contributor
 
Posts: 16
Joined: Thu Jul 28, 2022 3:38 pm

Next

Return to REST API

Who is online

Users browsing this forum: No registered users and 3 guests