providing dummy apis in wso2 api manager - wso2

Is there a way I can create some dummy APIs with dummy response in WSO2 API Manager? Our API implementation is not yet ready.Till its ready , can we create an API and give some sample json as response?

Best thing would be using the API manager to create API using prototype option.
Create API
Add entries for design screen
On the implementation screen choose - Prototyped API
Choose Implementation Method as inline for JSON (it will not work for
SOAP)
in Resource section click on any of the method types lets say Get
add the java script to mock the json data
/* mc.setProperty('CONTENT_TYPE', 'application/json');
enter code heremc.setPayloadJSON('{ "data" : "sample JSON"}');/
/ Uncomment the above comment block to send a sample response.*/
Publish it.
Hope this helps

Yes, you can create prototype API. please let me know if this help.
Refer following document Deploy and Test as a Prototype

If your servers has internet access, you can use http://www.mocky.io/ to mock your response. When you are creating an API in WSO2 API Manager provide the url of the mocky.io as the endpoint.

Related

Can't find "service_token"

Is there someone who can't explain to me, how to generate "service_token" from this API.
I already create get request with "basket_token" using "RESTful API of Request Baskets service." for this API and it was pretty easy.
But now I have to create get request for this one and I need service_token.
Thank you in advance.
service_token is a master token that allows to access any basket created in Request Basket service, as well as it gives you an access to the statistics aross all baskets.
You cannot create this token through API.
It is automatically generated when you launch your own instance of the service and it is printed out to the system output.
Alternatively you can define your own service_token by using the command line argument -token, see description of configuration parameters.
By the way, version (https://rbaskets.in/api/version) is a public part of the API and it requires no authorization at all.

WSO2 EI REST API Manager Resource

I need to manage a Registry Resource deployed into the Enterprise Integrator.
Using the REST API like this:
https://localhost:9443/registry/resource/_system/governance/EstrattoContoEnti/xml/EstrattoContoEntiConf.xml
I can GET the resource, but...how can I modify this or create a new one?
Calling a PUT o POST I get Error 405 - Method Not Allowed.
Is there any API to manage the registry entries on the WSO2 EI?
Or may I need to use something else?
This is not possible out of the box via a REST API.
There is a AdminService for Registry and you may access that AdminService and get the related functionality via SOAP.
But in your case, since you are expecting a REST API, you can create a web-app client which will use this Admin-service, so that you have a REST API to the registry via this client.
There is already such a client written. Have a look at the steps on how to get this and configured from the following blog.
http://abeykoon.blogspot.com/2015/04/wso2-gov-registry-using-registry-api.html
Cheers.

WSO2 APIM : Get API Rating and Business Information through Store REST API

I have a custom page where I obtain Published API list using WSO2 Store Restful API
https://docs.wso2.com/display/AM220/apidocs/store/#!/operations#APICollection#apisGet
The problem is the returned result does not includes API Rating and Business Information whereas the Jaggery API that has been used by the default API Manager UI does include it. Is there any way to configure it so the REST API returns that data?
If I use the jaggery API instead, it is cookie based while I am using OAuth2 OIDC Service Provider of the IS. I cant obtain API that has visibility to only its own domain by passing access token to the Authorization header.
APIM Version: 2.2
Please Advice. Thanks!
There is no such a way which will change the output response of defined APIs.
If you want to do that, get source code of wso2 from github & edit the APIs & use the edited source to deploy your application. (But this will add lots of maintenance issue)
The quickest way is to call the get details of api.
It will return the business information object as well as below:
"businessInformation": {
"technicalOwner": "John Doe",
"technicalOwnerEmail": "architecture#pizzashack.com",
"businessOwner": "Jane Roe",
"businessOwnerEmail": "marketing#pizzashack.com"
},
Here you will get the heavy response as it returns the complete swagger definition as well.

How to have multiple endpoints for one API in WSO2 API Manager?

Can I add multiple endpoints to 1 API in WSO2 Api Manager?
As far as I know I have to create a context and a version. The background is that I just want to make a request like https://api.manager.com/rest/1.0/userList or https://api.manager.com/rest/1.0/tasks.
The userList REST-Controller is implemented on backend A and tasks REST-Controller is implemented in backend B. (A and B are separate web applications)
As far as I know I have to create in my API Manager two APIs with different context values.
The API Manager application would simply subscribe both APIs.
But this would mean that I have to change my requests on the javascript side. This is in my opinion not good because I dont want my javascript application to care about the context. I want that the API Manager delegates to the correct backend automatically. Is this possible? What is best practise?
You can have multiple endpoints per API using Dynamic Endpoint Feature. When creating the API you need to set the Endpoint Type as "Dynamic Endpoint" and upload a mediation in-sequence that sets the "To" header. Within the sequence you can specify your logic to route to the correct endpoint (setting the correct "To" header) according to the request path. Please read [1] for more information.
[1] http://blog.lakmali.com/2016/08/dynamic-endpoints-in-wso2-api-manager.html

Get the name of the Application that triggers a call from WSO2 API Manager

Is it possible to get the name of the Application that triggered the API call on WSO2 API Manager and pass it on to the call as a header?
Any can help how to do this please.
Yes, application name is part of the JWT token that you get with the calls. Here's documentation.
JWT tokens are enabled by default in WSO2 API Cloud (the public hosted service from WSO2). So if you are using it - everything just works.
If you are deploying API Manager yourself, you need to configure JWT yourself as explained here.
One option would be to implement an custom handler. See Writing Custom Handlers
APIMgtUsageHandler is one of the handlers in API manager which collects the application name (to collect usage data). So you can refer it as a sample handler on how to get the application name. see APIMgtUsageHandler.java