I created a Rest API using Rest API Descriptor in designer. Is there any way to create API URL without using API Gateway(we are not using in present Org) which should be shared to vendor using proxy server. If any please help to know me.
Sharing the Swagger file is the only way without API gateway?
You don’t necessarily need the API Gateway. When you have a REST API Descriptor, the path to interact with your API will be rad/[path to the REST API descriptor] by default. So, for example, if you consider the following package:
The URL path to interact with the greetings API would be rad/pc.greetings.API:greetings, meaning a consumer of this API would be able to interact with it by using the base URL https://server:port/rad/pc.greetings.API:greetings.
Now, that is a somewhat ugly path to expose to external clients. Plus, it gives away too much detail about the underlying implementation. So, in the absence of an API Gateway, I like to use the Integration Server’s URL Aliases feature to abstract the actual path from the consumer. For example:
Now, consumers can use the friendlier URL https://server:port/API/greetings instead.
Planning these friendly URLs ahead of time is useful as you can include them in your API definition (e.g. Swagger) from the get-go. Now, in order to use URL aliases in this manner, the IS extended setting watt.server.url.alias.partialMatching needs to be set to true.
Hope this helps,
Percio
PS. The TECHcommunity editor makes every occurrence of the word ‘API’ uppercase automatically for some annoying reason but imagine the paths above have ‘API’ as lowercase to match the screenshots.
That base URL is pointing to the REST API Descriptor. You now need to add the resource to the end of the URL so you can perform the operation against the resource, e.g.: http://hostname:port/rad/TEST.WS:addAPI_test/resource
This is why the partialMatching setting needs to be set to true.
By the way, to have the IS automatically generate the URL alias when you import the Swagger file, add the path you want to use as the basePath in the swagger, e.g.
The URL alias definition is stored in the file config/urlalias.cnf inside your package, so when you deploy the package to higher environments, the URL alias gets created automatically.
I tried with same you have explained, but i’m facing with error “404-Object not found” . The path am using is correct but unable to use the URL. I’m using wM version-10.1, here we can’t edit , as is set as “restv2”
Sorry for the delayed response. Were you able to figure out your issue?
It’s been a while since I touched 10.1 or played with RESTv2 so my memory is a bit foggy on how you configure them. However, invoking a REST v2 resource directly via the /restv2 directive is slightly different than invoking the REST resource via a REST API Descriptor (i.e. via the /rad directive).
In order to mimic what you have with the RESTv2 resource, I did the following:
I created a service called getResult which takes two integers as input, num1 and num2, and the desired operation (e.g. add, subtract, etc), and then it performs that operation by calling one of the WmPublic math services
I then created a REST Resource called result
I configured the REST Resource so when the GET method is used against the resource using the URI template /result, it invokes my service
Note that the URL is the “Template prefix” from the REST resource properties with the “URL Template” appended to it.
Now, this URL is not the prettiest thing in the world, so as we discussed before, you can use a URL alias to “prettify” and abstract the actual physical path. E.g.: