C8Y application requiring a second login

I recently changed my user password for my C8Y account, and since then one of my applications is requiring me to authenticate a second time.

The only problem is that when I add my credentials, the application returns a 401 error.

Hi @luclib,

Do you have some more details to when this issue occurs?
Is it happening during local development or when your application is actually deployed to your cloud environment?
Does it only happen with your custom developed applications or also in the default apps?
Is it always a specific request that fails?

It seems you are calling a custom endpoint /service/templates-basic/api/ErrorLogsAnalysis from a microservice here.
Can you provide the code snipped of the UI that makes this call?


Hi Tristan,

So, the above screens were taken with the apps already uploaded onto the Cumulocity tenant.

I tried with the version on my localhost and, this time, it did not requesting additional authentication but it is still returning error messages.

Here is the code snippet

Could it have something to do with my login settings?

Hi Lucas,

my guess it that you are not adding the correct request headers to your http.post call.
If you would use the FetchClient that is part of @c8y/client you would have all the required headers attached to your request.


Hi Tristan,

I tried refactoring my code as follows:

 const options: IFetchOptions = {
            method: 'POST',
            headers: { 'Authorization': environment.postApiKey },
            body: formData

 const response = await this.fetchClient.fetch(environment.postUrl, options);

 const res = await response.json();
 this.repairStrategyList = res['repairStrategyList'];
 this.parts = res['parts'];
 let logs = res['reponseObject'];

Now I am getting a different error type:

Can you also show the environment.postUrl and formData parts?

Of course.

Here is the formData part:

const formData = new FormData(); 
        for(let file of this.fileList){
            formData.append('file', file);

And the postUrl is as follows

postUrl: 'https://novanta.us.cumulocity.com/service/templates-basic/api/ErrorLogsAnalysis'

So the postUrl part, you want to change to just: /service/templates-basic/api/ErrorLogsAnalysis.
As this might otherwise cause issues during local development.

From where did you import FormData?
Can you give it a try with just an empty string as body? To see if it then performs at least the request?

Hi Tristan,

I changed the postUrl to just service/templates-basic/api/ErrorLogsAnalysis and it returned the same 401 error as before

The FormData is not imported from anywhere and is part of the XMLHttpRequest API.

When I send it without appending anything to the new object, I get this error instead


I don’t get it: why is there an authorization header in your fetch request?
Please remove that, you don’t need it if this app is supposed to run in Cumulocity.