Route defined in Swagger specification (/sales) but there is no defined get operation - ibm-cloud

I am creating APIs with importing existing APIs from swagger JSON file to a Bluemix API Connect environment. When I use Invoke to test a post API I get the following error:
405 Method Not Allowed Content-Type: text/html Error: Route defined in
Swagger specification (/sales) but there is no defined get
operation. at send405
(/home/vcap/app/node_modules/swagger-tools/middleware/swagger-router.js
Any experience with POST request with Bluemix API Connnect?

There are several reasons why this can happen.
Here are some:
you need to define a tag for each operation.
this tag is not allowed to have special characters, such as -.

Related

HTTP Options method is not working as expected

I have a Jersey 2.x application running in tomcat. All the method implementations are working as expected, and even I am able to get WADL by navigating to http://{host}:{port}/JerseyRESTWebapp/ws/rest/application.wadl.
Everything is great so far.
Now, Out of curiosity I tried navigating to http://{host}:{port}/JerseyRESTWebapp/ws/rest/employees URL using using HTTP OPTIONS method expecting i will get 405 Method not allowed but i got the 200 OK and response body contains the WADL. Can someone let me know why is this happening? I am using POSTMAN chrome extension as REST client.
Also in the Response Allow Header, i am getting POST,GET,DELETE,OPTIONS,HEAD. I am missing PUT method here. why?
This is how the resource discovery works by default. It's implemented to follow the spec in regards to OPTIONS resource discovery
This method allows the client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval.
If you want to disable the WADL, you can by setting the property ServerProperties.WADL_FEATURE_DISABLE to true.
If you're curious about how this is implemented, check out the source for the WadlModelProcessor. It goes through all the resource models and adds an extra OPTIONS resource method. You can read more about the ModelProcessor in the Jersey docs Programmatic API for Building Resources

Model HTTP POST with URL query parameters in swagger 2.0

Newbie question: I have to rebuilt an old REST API, with some clients in Swagger 2.0. Unfortunatly some of the API calls use for HTTP post the following way: For the content it uses the POST body, but for a "sitekey" it use an URL Parameter.
so each post looks something like that:
POST api/update?sitekey=xxx HTTP/1.1
....
{"json": "content"}
I must not ignore the sitekey, so how would i model such a thing in swagger?
If you are using Jax-rs, you can use swagger's #ApiParam annotation. Depending on the jax-rs annotation (#QueryParam, #PathParam, etc.) used along with this annotation, swagger will identify the parameter placement correctly. See here: https://github.com/swagger-api/swagger-core/wiki/Annotations#apiparam

Get non file body from multipart/form-data using AWS API Gateway and Lambda

I am trying to get the form data from a multipart/form-data POST to my ASW Lambda web service via API Gateway.
The HTTP POST has Content-Type "multipart/form-data" and body that is URL encoded. File data is also sent in this post (hence the multipart, I guess).
The web service needs to integrate with a thirdparty service, so changing the format of the POST isn't really an option.
I have seen this thread talking about converting the URL encoded data to JSON object for use in Lambda, but this doesn't do the trick.
I have also tried setting the Integration Request -> Mapping Templates for content type multipart/form-data to Input passthrough. This didn't help either.
I did come across another question about uploading a file using multipart/form-data, but since I'm not interested in the file, just the body, that answer didn't help.
Below find screenshot (sorry) of the captured post via runscope.
If the goal is to use Lambda, you'll need to pass valid JSON to the function. Currently there isn't a way to JSON-ify data inside Api Gateway that comes in as non-JSON data.
Our short term fix (on our backlog) is to provide a variable in the mapping templates to grab the raw input of the request. That way you could do a simple JSON conversion using a template like:
{
"body" : "$input.body"
}
or something like that.
Check out the mapping template reference for more info: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
Edit 4/7 - feature has been released as $input.body

Can you POST in a GET Method in Rest services?

I am working on a SoapUI automation project for Restful service.I'm new to SoapUi and Restful services itself.
I have the Rest API generated in SoapUI. I don't have any sample requests given by the developer so I am working on creating the requests myself. I only have a JSON contract document to refer to which was created for the UI developers. Now according to the specification documents, some get methods in the API's are supposed to have two parameters "token" and "ContextName". However, when I imported the WADL file in SoapUI, the request body only has the "token" parameter. So am I manually supposed to add the other missing parameter in my requests? and is it possible to create a POST(rest test request) in a GET resource?
I don't think you can have multiple body parameters (or if you can, it's certainly not a good practice!). Check to see if the ContextName parameter is a different type of parameter such as a query or path parameter (called template parameter in SoapUI). Here is some info about different types of REST parameters in SoapUI: http://www.soapui.org/rest-testing/understanding-rest-parameters.html
I'm not sure what you mean in your second question. Perhaps you want to write a Test Case with multiple Test Steps (a GET and a POST)? Check out this link: http://www.soapui.org/functional-testing/structuring-and-running-tests.html Also look at the other sections under Functional Testing to learn how to control the flow of test steps.

wso2 api manager 1.6.0 query parameters not accepted

I am using wso2 API manager 1.6.0 and would like to create an API which accepts any POST
on /users resource followed by any query parameter such as "clientid" (as described below)
restserver.com:8280/context/1/users?clientid=333
I have created an API in API publisher as follow :
URL Prefix URL Pattern HTTP Verb
/context/1 /users/* POST
Any POST on /users is accepted but as sson as I add a query paramter /users?clientid=333 , the request is rejected by the API Manager gateway with 403 error.
Could someone advice me on this and what should be the correct url-mapping format ?
The resulting url-mapping in synapse config file is as follow : (synapse-configs/default/api/)
Thanks a lot.
JS
For this you need to define uri-template instead of uri-mapping. This blog post explains more about this.
For your case I got it working as following.
Open your API configuration source which can be found at AM_HOME\repository\deployment\server\synapse-configs\default\api folder.
In the resource tag change url-mapping="/users/*" attribute to uri-template="/users/*"
But you will have to invoke the API as follows with additional context because when you say /users/* it means anything can come after users/. So you need to have a / after users context.
restserver.com:8280/context/1/users/usr?clientid=333