[prev in list] [next in list] [prev in thread] [next in thread] 

List:       esb-java-dev
Subject:    Re: [Dev] Struggling to create a API using official publisher REST APIs document.
From:       Pasindu Jayaweera <pasinduj () wso2 ! com>
Date:       2019-11-25 2:30:31
Message-ID: CA+z_hBBx+JrTzGvAx+wz0KXh8D7PT_F6dH0eqP-P1hW2DgTMpw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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 <shiva.k@securelyshare.com>
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\":\"s \
> tring\"},\"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\"},\"or \
> derId\":{\"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\":\"architecture@pizzashack.com\",\"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": "marketing@pizzashack.com",
> "technicalOwnerEmail": "architecture@pizzashack.com",
> "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
> Dev@wso2.org
> 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>


[Attachment #5 (text/html)]

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




_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic