How to create API URL without API gateway

Hi all,

we are using wM 10.1 version ,

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?

Thanks & Regards
KN

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:

image

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. :slight_smile:

1 Like

Hi Percio,

Thankyou for your content.

URL : http:/hostname:port/rad/TEST.WS:addAPI_test

I tried the way you have explained but im facing the error as below when try to test in postman , can please give me a solution for this error.

404No such object: rad%2fTEST.WS%3aaddAPI_test

Thanks & Regards
KN

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.

Hope this helps,
Percio

Thanks Percio,

http://hostname:port/rad/TEST.WS:addAPI_test/resource

resource means you are mentioning about rest resource or any other.

Thanks
KN

Correct, REST resource.

To further illustrate, let’s take the PcGreetings package as an example again. If we look at the REST resources defined there, you will find this:

image

Both resources support the GET HTTP method. If I then want to GET a hello greeting from this API via Postman, I can either use the RAD path:

… or I can use the URL alias I defined:

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.

image

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.

Good luck,
Percio

Dear Percio,

Thankyou for your clear and precise explanation.

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”
image

Base path can’t be changed, as like in above 10.3 versions.

I tested with swagger file and getting response.

If any please help me in this.

Thankyou in advance.

Regards
KN

@nikil,

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:

  1. 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
  2. I then created a REST Resource called result
  3. I configured the REST Resource so when the GET method is used against the resource using the URI template /result, it invokes my service

image

With this configuration, I can then perform a GET against this resource from Postman as follows:

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.:

And now I can perform the operation from Postman as follows:

image

Hope this helps,
Percio

1 Like

Dear Precio,

Thank you for your support & letting me to know things that i am not aware in detail.

Need your continuous support in future.

Once again thank you for detail explanation.

Thanks & Regards
KN

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.