0

At WSO2 Integration Studio, I want to create an API that takes the query parameter from outside.

In the API I will create, I have an API that takes query parameters in the same way. How can I send this query parameter, to the API I'm going to consume?

enter image description here

Ahmet Kalem
  • 113
  • 6

1 Answers1

0

Here is how you can extract aincoming Query param and add it to the outgoing request.

#Incoming Request
http://localhost:8290/currency?name=123456

#Outgoing Request
https://jsonplaceholder.typicode.com/todos?id=123456

API

<?xml version="1.0" encoding="UTF-8"?>
<api context="/test" name="ScienceLabAPI" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="POST">
        <inSequence>
            <property description="Extracting Param value from incoming request" expression="$url:name" name="uri.var.ep.name" scope="default" type="STRING"/>
            <log>
                <property expression="$ctx:ep.name" name="NAME"/>
            </log>
            <property action="remove" name="REST_URL_POSTFIX" scope="axis2"/>
            <call>
                <endpoint>
                    <http method="GET" uri-template="https://jsonplaceholder.typicode.com/todos?id={uri.var.ep.name}">
                        <suspendOnFailure>
                            <initialDuration>-1</initialDuration>
                            <progressionFactor>-1</progressionFactor>
                            <maximumDuration>0</maximumDuration>
                        </suspendOnFailure>
                        <markForSuspension>
                            <retriesBeforeSuspension>0</retriesBeforeSuspension>
                        </markForSuspension>
                    </http>
                </endpoint>
            </call>
            <respond/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>
ycr
  • 12,828
  • 2
  • 25
  • 45