Hi Shiva, As per your message, it seems you are sending a PUT request. But to create a new API, you should be sending a *POST* request. (PUT is used to update an existing API) Try with POST request and check.
Regards, On Wed, Nov 13, 2019 at 2:58 AM Shiva Kumar <[email protected]> wrote: > Hi Team, > > I am following below document and I could not able understand how to > create an API using WSO2 APIM 2.1.0 Publish APIs below is the document I > am following but getting 403 forbidden. Below are the steps I followed. > > 1. I created an oauth application from admin console. > > 2. I used admin user and it's password to get password grant type token > with scopes apim:api_create, apim:api_view, apim:api_publish. > > 3. I used the token obtained from above step and used sample payload > given in document > > https://docs.wso2.com/display/AM210/apidocs/publisher/#!/operations#APIIndividual#apisPost > to create an API. > > 4. Got 403 forbidden response. > > > Request: > > PUT http://localhost:9773/api/am/publisher/v0.11/apis > > { > "name": "PizzaShackAPI", > "description": "This document describe a RESTFul API for Pizza > Shack online pizza delivery store.\r\n", > "context": "/pizzashack", > "version": "1.0.0", > "provider": "admin", > "apiDefinition": > "{\"paths\":{\"/order\":{\"post\":{\"x-auth-type\":\"Application & > Application > User\",\"x-throttling-tier\":\"Unlimited\",\"description\":\"Create a > new > Order\",\"parameters\":[{\"schema\":{\"$ref\":\"#/definitions/Order\"},\"description\":\"Order > > object that needs to be > added\",\"name\":\"body\",\"required\":true,\"in\":\"body\"}],\"responses\":{\"201\":{\"headers\":{\"Location\":{\"description\":\"The > > URL of the newly created > resource.\",\"type\":\"string\"}},\"schema\":{\"$ref\":\"#/definitions/Order\"},\"description\":\"Created.\"}}}},\"/menu\":{\"get\":{\"x-auth-type\":\"Application > > & Application > User\",\"x-throttling-tier\":\"Unlimited\",\"description\":\"Return a > list of available menu > items\",\"parameters\":[],\"responses\":{\"200\":{\"headers\":{},\"schema\":{\"title\":\"Menu\",\"properties\":{\"list\":{\"items\":{\"$ref\":\"#/definitions/MenuItem\"},\"type\":\"array\"}},\"type\":\"object\"},\"description\":\"OK.\"}}}}},\"schemes\":[\"https\"],\"produces\":[\"application/json\"],\"swagger\":\"2.0\",\"definitions\":{\"MenuItem\":{\"title\":\"Pizza > > menu > Item\",\"properties\":{\"price\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"},\"image\":{\"type\":\"string\"}},\"required\":[\"name\"]},\"Order\":{\"title\":\"Pizza > > Order\",\"properties\":{\"customerName\":{\"type\":\"string\"},\"delivered\":{\"type\":\"boolean\"},\"address\":{\"type\":\"string\"},\"pizzaType\":{\"type\":\"string\"},\"creditCardNumber\":{\"type\":\"string\"},\"quantity\":{\"type\":\"number\"},\"orderId\":{\"type\":\"integer\"}},\"required\":[\"orderId\"]}},\"consumes\":[\"application/json\"],\"info\":{\"title\":\"PizzaShackAPI\",\"description\":\"This > > document describe a RESTFul API for Pizza Shack online pizza delivery > store.\\n\",\"license\":{\"name\":\"Apache > 2.0\",\"url\":\"http://www.apache.org/licenses/LICENSE-2.0.html\ > "},\"contact\":{\"email\":\"[email protected]\",\"name\":\"John > Doe\",\"url\":\"http://www.pizzashack.com\"},\"version\":\"1.0.0\"}}", > "wsdlUri": null, > "responseCaching": "Disabled", > "cacheTimeout": 300, > "destinationStatsEnabled": false, > "isDefaultVersion": false, > "type": "HTTP", > "transport": [ > "http", > "https" > ], > "tags": [ > "pizza" > ], > "tiers": [ > "Unlimited" > ], > "maxTps": { > "sandbox": 5000, > "production": 1000 > }, > "visibility": "PUBLIC", > "visibleRoles": [], > "endpointConfig": > "{\"production_endpoints\":{\"url\":\" > https://localhost:9443/am/sample/pizzashack/v1/api/\ > ",\"config\":null},\"sandbox_endpoints\":{\"url\":\" > https://localhost:9443/am/sample/pizzashack/v1/api/\ > ",\"config\":null},\"endpoint_type\":\"http\"}", > "endpointSecurity": { > "username": "user", > "type": "basic", > "password": "pass" > }, > "gatewayEnvironments": "Production and Sandbox", > "sequences": [], > "subscriptionAvailability": null, > "subscriptionAvailableTenants": [], > "businessInformation": { > "businessOwnerEmail": "[email protected]", > "technicalOwnerEmail": "[email protected]", > "technicalOwner": "John Doe", > "businessOwner": "Jane Roe" > }, > "corsConfiguration": { > "accessControlAllowOrigins": [ > "*" > ], > "accessControlAllowHeaders": [ > "authorization", > "Access-Control-Allow-Origin", > "Content-Type", > "SOAPAction" > ], > "accessControlAllowMethods": [ > "GET", > "PUT", > "POST", > "DELETE", > "PATCH", > "OPTIONS" > ], > "accessControlAllowCredentials": false, > "corsConfigurationEnabled": false > } > } > > Response: > > Error 403 - Forbidden > > > Thank You, > > Shiva > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > -- *Pasindu Jayaweera *| Senior Software Engineer | WSO2 Inc Mobile: +94 711555785 | Blog: blog.pasindujayaweera.com <http://wso2.com/signature>
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
