WSO2 API with C#.Net Back-end Service: 404 Error Reason and How to Resolve

By | November 20, 2019

While using WSO2 API Manager as API Management Platform and .Net based back-end REST Services, we were getting 404 error while same service was working fine when invoked directly from any client (e.g. postman) without involving WSO2 API Manager in the middle. In this post, I will explain what was the reason of this 404 Error and how we resolved it.

Possible Reasons of 404 Error for a Back-End service when using WSO2 API Manager

One obvious reason of receiving 404 Error is that the resource is not available on the given URL. For REST Service, to ensure that back-end service is up & running on the given URL, you can double check by trying to access it directly from any client like a browser, postman or SOAP UI tool. If it is not accessible even directly then you need to check with your back-end system and verify if the service is available. Some other basic health checks like ping & telnet can also be performed for this purpose to verify if server and service on the given port are up & available.

If you find that direct access to the back-end service is available and no issues with the back-end, next step is to verify from your API Publisher to ensure that URL specified in the implementation step is valid and other configurations like REST service VERB, transport protocol etc. are also fine.

To debug and find the reason more clearly, we enabled debug settings by updating log4j.properties file (WSO2_HOME/repository/conf/log4j.properties) as below:

log4j.logger.org.apache.synapse.transport.http.wire=DEBUG

Once you enable logging and restart your API management service, you will see that wire logs become available in your carbon.log file which can help you to look more closely for the request & response structure, content types and other useful log information.

For our issue with .Net based back-end service, we found from back-end IIS Server logs that request was landing on ISS Server with the wrong URL having suffix twice. E.g. if you have an API with back-end service available on the URL http://<HOST>:<PORT>/humans/search then It was sending it to the back-end with /search twice (http://<HOST>:<PORT>/humans/search/search) . To resolve this issue, in the API Publisher, we changed the back-end service URL and removed /search as this /Search was already configured in the API Definition when choosing POST method

Recommended Reading: WSO2 API Manager Beginners Tutorial: How to Publish and Subscribe APIs Using WSO2 API Publisher and Developer Portal

Ajmal Abbasi

Ajmal Hussain Abbasi is Integration Consultant By Profession with 13+ years experience in Integration domain mainly with TIBCO products. He has extensive practical knowledge of TIBCO Business Works, TIBCO Cloud, TIBCO Flogo, TIBCO Mashery, TIBCO Spotfire, EMS and TIBCO ActiveSpaces. He has worked on a number of highly critical integration projects in various sectors by using his skills in TIBCO Flogo, TIBCO API Management (Mashery), TCI, Tibco Designer, TIBCO Business Studio, Adapters, TIBCO EMS, RV, Administrator, TIBCO BE, TIBCO ActiveSpaces etc. Ajmal Abbasi has experience with MuleSoft ESB as well. Ajmal Abbasi is also experienced in the area of API Management particularly with WSO2 API management platforms. Ajmal Abbasi is also experienced in developing solutions using Core Java and J2EE Technologies. You can contact Ajmal Abbasi for Consultancy, Technical Assistance and Technical Discussions.

More Posts - Website - Facebook - LinkedIn - YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *