Swagger API with Cumulocity Microservice

What product/components do you use and which version/fix level are you on?

Cumulocity 1014

Is your question related to the free trial, or to a production (customer) instance?

Cutomer Instance

What are you trying to achieve? Please describe it in detail.

I have developed a Spring boot java microservice for C8y. I wanted to generate swagger API documentation and therefore added the relevant annotations. It works perfectly fine locally but on the tenant i am unable to see the UI.

Do you get any error messages? Please provide a full error message screenshot and log file.

I get the following error:
{“message”:“tenantId/arsalanmahmood.siddiqi@softwareag.com cannot access endpoint: /service/unit-conversion-ms/swagger-ui/index.html. Reason: The user agent is forbidden for Basic Authentication. : The user agent is forbidden for Basic Authentication.”,“error”:“general/internalError”,“info”:“https://cumulocity.com/guides/reference/openapi/”}

This one might help here: Cumulocity API calls resulting in Invalid credentials

Hi Arsalan,

Hosting an UI within a microservice is sadly not really possible with Cumulocity as all requests to the microservice need to be authorized. I guess in your case, the tenant is configured to block Basic Auth usage in web browsers:

You could try disabling it, but it will probably still not really be user friendly.

There are already some ideas around about exposing certain microservice endpoints:
https://cumulocityiot.ideas.aha.io/ideas/C8YCORE-I-17

Regards,
Tristan

This actually worked! thankyou tristan