Apache Nifi Rest Api Authorization
I want to stop a processor on the same machine with restApi but I get an authorization error when I call the rest api.I can solve this problem with bearer token, but since the token has expired, I need to change the bearer token manually again.Is there a way I can authorize automatically?
- I am using the executeScript processor when calling the API.Script engine is Groovy.
- My Nifi version 1.23.2 and Nifi is secure and not clustered.I login with ldap on UI.

This is the part where I call the API in the script:
def post = new URL(NifiBaseUrl.value + NifiComponentId.value).openConnection();
post.setSSLSocketFactory(sslContext.getSocketFactory())
post.setRequestMethod("PUT")
post.setDoOutput(true)
post.setRequestProperty("Content-Type", "application/json")
post.getOutputStream().write(content.getBytes("UTF-8"));
post.getResponseCode()
Error:
java.io.IOException: Server returned HTTP response code: 401 for URL

