Home Ask Login Register

Developers Planet

Your answer is one click away!

GSAN February 2016

Passing Username and Password to a REST API in WSO2 ESB

I am using and REST API in wso2 ESB to call another service with Basic authentication.

This is my API code:

<resource methods="POST" uri-template="/deleteZoneFromEnrolment/">
     <property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode('user:password'))" scope="transport"></property>
     <property name="DISABLE_CHUNKING" value="true" scope="axis2"></property>
     <payloadFactory media-type="xml">
           <enr:DeleteZoneFromEnrolment xmlns:enr="http://someURL/Enrolment.xsd">
           <arg evaluator="json" expression="$.enrolment"></arg>
           <arg evaluator="json" expression="$.zone"></arg>
        <endpoint key="dev_enrolmentEndpoint"></endpoint>
     <log level="full"></log>
     <property name="messageType" value="application/json" scope="axis2" type="STRING"></property>
     <sequence key="esb_error_handling_response"></sequence>

I call this REST API using a json POST like this:


If I hardcode the user and password, It work nicely. But I`m going one step forward. I need to pass this Basic Authorization with a post JSON that I use to call the REST API in the ESB or setting up this API to pass Authentication through a GET/POST call.

Does anyone know how to do it? This is what I am trying bu


GSAN February 2016

I finally resolved. It is easier than I thought, just adding Basic Auth header inside my app (when I'm calling my ESB API) with username and password and the credentials are passing through my API to the external service.

Post Status

Asked in February 2016
Viewed 2,477 times
Voted 10
Answered 1 times


Leave an answer

Quote of the day: live life