This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Create an API with an Inline Script
- Log in to the API Publisher.
Click the Add link and provide the information given in the table below.
Field  Sample value Name  Location_API Context  /locationVersion  1.0.0 Resources URL pattern town/{name}  Request types GET
After the resource is added, expand itsÂ
GET
 method and note that a parameter by the name town is added under the resource. You use it to pass the payload to the backend. Once done, click Implement.
ÂUnder the Implement tab, click the implementation method as Inline expand the GET method and give the following as the script. It reads the payload (i.e., the name of the town) that the user sends with the API request and returns it as a JSON value.
mc.setProperty('CONTENT_TYPE', 'application/json'); var name = mc.getProperty('uri.var.name'); mc.setPayloadJSON('{ "Town" : "'+name+'"}');
Click the Deploy Prototype button.
Go to the API Store, click the Prototyped APIs menu and note that the newly deployed API is listed there.
Tip: You can invoke prototyped APIs without signing in to the API Store or subscribing to the API. The purpose of a prototype is advertising and giving an early implementation for users to test.
Click the API to open it and go to its API Console tab.
Â- Expand the GET method, give any name for the town (say London) and invoke the API.
 Note the payload you gave as a JSON output in the response.
Â
You have created an API with inline script, deployed it as a prototype and invoked it through the integrated API Console.