Trying to invoke a basic REST GET operation from browser and Postman.
From browser, the URL is http://localhost:7800/restrequest_api/v1/4
Where 4 is the UserNumber I'm passing.
It is getting invoked successfully.
But from PostMan I couldn't invoke it.
Tried http://localhost:7800/restrequest_api/v1
with Content-Type
header as application/x-www-form-urlencoded
and selected body as x-www-form-urlencoded
with a Key UserNumber and Value 4
This is giving error as
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>404 Not Found</title>
</head>
<body>
<h1>404 Not Found</h1>
<p>
BIP6311E: REST API ''RESTRequest_API'' does not support method ''GET'' for URL
''http://localhost:7800/restrequest_api/v1''.
</p>
<hr>
</body>
</html>
Please Note: CORS are enabled:
mqsichangeproperties TESTNODE_hghatak -e default -o HTTPConnector -n corsEnabled -v true
mqsichangeproperties TESTNODE_hghatak -b httplistener -o HTTPConnector -n corsEnabled -v true
mqsistop TESTNODE_hghatak
mqsistart TESTNODE_hghatak
Below is the Swagger file which I used for development:
{
"swagger" : "2.0",
"info" : {
"title" : "RESTRequest_API",
"version" : "1.0.0",
"description" : "RESTRequest_API"
},
"paths" : {
"/{UserNumber}" : {
"get" : {
"operationId" : "getUser",
"responses" : {
"200" : {
"description" : "The operation was successful.",
"schema" : {
"$ref" : "#/definitions/Output"
}
}
},
"produces" : [ "application/json" ],
"description" : "Retrieve User",
"parameters" : [ {
"required" : true,
"name" : "UserNumber",
"in" : "path",
"type" : "string"
} ]
}
}
},
"basePath" : "/restrequest_api/v1",
"definitions" : {
"Output" : {
"type" : "object",
"properties" : {
"firstName" : {
"type" : "string"
},
"lastName" : {
"type" : "string"
},
"userDetails" : {
"type" : "string"
},
"userNumber" : {
"type" : "string"
}
}
}
},
"host" : "localhost:7800"
}
what is the issue?
Just select GET as your operation in POSTMAN and in BODY tab in postman select "none" option. Ensure you are using the same URL in postman as you are using in browser i.e. http://localhost:7800/restrequest_api/v1/4
Your swagger file indicates that its a GET operation being performed hence there is no requirement of payload being sent. So choosing the content-type is not applicable. In the parameters section of the swagger file, the following is mentioned "in" : "path", which means that you have to pass a path parameter in your url i.e. http://localhost:7800/restrequest_api/v1/4 where 4 is your path parameter in your example. You can go through the following postman link that provides further details on sending parameters => https://learning.postman.com/docs/postman/sending-api-requests/requests/#sending-parameters