trying to disable attachment notification
Asked by Sergio _:

according to this workarround.  

<https://confluence.atlassian.com/confkb/how-to-disable-notifications-for-attachments-action-862622270.html>  

I need to disable notifications when an attachments is uploaded in confluence.  

I did a Groovy code to perform it.  
But The response is allways 401  
"subCode": "upm.websudo.error"

Tried with basic and bearer token autentificaci?n  

*** ** * ** ***

```
import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

URL url = new URL("MYCONFLUENCEURL/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-file-notifications-key/modules/file-content-remove-notification-key");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("PUT");

httpConn.setRequestProperty("Content-Type", "application/vnd.atl.plugins.plugin.module+json");


httpConn.setRequestProperty("Authorization", "Bearer " + "MYTOKEN");

httpConn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());
writer.write("{\n \"enabled\": false\n}");
writer.flush();
writer.close();
httpConn.getOutputStream().close();

InputStream responseStream = httpConn.getResponseCode() / 100 == 2
? httpConn.getInputStream()
: httpConn.getErrorStream();
Scanner s = new Scanner(responseStream).useDelimiter("\\A");
String response = s.hasNext() ? s.next() : "";
log.warn(response);





```

Regards,


Answers:
author: Thiago Masutti
body: Hi [@Sergio _](/t5/user/viewprofilepage/user-id/558545)

You may need to temporarily [disable the websudo](https://confluence.atlassian.com/doc/configuring-secure-administrator-sessions-218269595.html) feature while running that script.

Is this an option to your use case?

Kind regards,  
Thiago Masutti

comments: author: Sergio _
body: Hi thiago. It is working disable the sudo option.  

Do you know how to do a rollback?  

<br />

I tried

```
writer.write("{\n \"enabled\": true\n}");
```

but it is not working  

Thanks


author: Thiago Masutti
body: That should be it.

What is the output you get when trying to enable it?


author: Sergio _
body: 2022-03-28 17:13:00,528 WARN \[runner.ScriptBindingsManager\]: 500  


author: Sergio _
body: \<status\>  
\<status-code\>500\</status-code\>  
\<message\>The module class cannot be determined, likely because it needs a concrete module type defined in the generic type it passes to AbstractModuleDescriptor\</message\>  
\<stack-trace\>java.lang.IllegalStateException: The module class cannot be determined, likely because it needs a concrete module type defined in the generic type it passes to AbstractModuleDescriptor


author: Thiago Masutti
body: Yeah, I got the same problem when trying to enable that module. Seems like you can't simply re-enable it.

I was able to revert it by disabling the full App and then enabling it again.

```
--- disable system App

curl -vvv -k -L -X PUT \
   -H 'Content-Type: application/vnd.atl.plugins.plugin+json' -u admin:admin \
   ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-file-notifications-key' \
   -d '{ "enabled": false }'

--- enable system App

curl -vvv -k -L -X PUT \
   -H 'Content-Type: application/vnd.atl.plugins.plugin+json' -u admin:admin \
   ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-file-notifications-key' \
   -d '{ "enabled": true }'

```

While testing I couldn't find any other consequences on this action, but I would strongly checking that on your lower instance first.  
Kind regards,  
Thiago Masutti


author: Thiago Masutti
body: Sergio.

In regards to your original issue with websudo, I've created a new bug as I understand this should bypass the websudo requirement when using PAT.

[UPM-6129](https://ecosystem.atlassian.net/browse/UPM-6129) -- When websudo is enabled then UPM REST API fails with 401 Unauthorized response when authenticating with personal access token

Kind regards,  
Thiago Masutti


author: Sergio _
body: Sorry for my low knowledge. What do you mean about disable/enabled full system app?  

regards.


author: Thiago Masutti
body: Hi Sergio.

That means you should disable and then enable the entire Plugin (Confluence File Notification) instead of just trying to enable the module.

You may try the following API calls to accomplish that.

```
--- disable system App

curl -vvv -k -L -X PUT \
   -H 'Content-Type: application/vnd.atl.plugins.plugin+json' -u admin:admin \
   ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-file-notifications-key' \
   -d '{ "enabled": false }'

--- enable system App

curl -vvv -k -L -X PUT \
   -H 'Content-Type: application/vnd.atl.plugins.plugin+json' -u admin:admin \
   ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-file-notifications-key' \
   -d '{ "enabled": true }'
```

Kind regards,  
Thiago Masutti


author: Sergio _
body: thanks Thiago for your help.


author: Sergio _
body: [@Thiago Masutti](/t5/user/viewprofilepage/user-id/1209618)   

what about versioning notifications. I need to disable those notifications too.  

Can I do the same disabling file-notifications-file-details-file-version module?  

Regards.  

<br />


Tags: confluence-server

notification

server