belfastcowboy24
belfastcowboy24

Reputation: 317

How can I get the token to use the REST API in a user and password protected instance of NiFi?

I have a NiFi instance running on a Docker container and, and I'd like to get some information about it through its API. To do so, I have followed the steps indicated here: https://community.hortonworks.com/questions/96383/how-to-get-the-access-token-by-invoking-nifi-rest.html, using this command:

curl 'http://<my_nifi_ip>:<my_nifi_port>/nifi/nifi-api/access/token' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' --data 'username=<my_user>&password=<my_password>' --compressed

But, when launching this command, it redirects me to the login page of NiFi

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="/login.html">here</a>.</p>
</body></html>

How can I solve my problem to get the token?

Thank you for your help. Regards.

Upvotes: 0

Views: 896

Answers (1)

Bryan Bende
Bryan Bende

Reputation: 18630

The URL in the curl command needs to be 'https' instead of 'http', and the path is a little bit off and should not have the /nifi in front of /nifi-api.

You can cross-check against the curl command in the community post you linked to which I think has the correct command.

Upvotes: 2

Related Questions