Member since
05-01-2017
5
Posts
0
Kudos Received
1
Solution
My Accepted Solutions
Title | Views | Posted |
---|---|---|
1419 | 01-21-2020 06:02 AM |
01-21-2020
06:02 AM
I found the solution myself import requests headers = { 'Content-Type': 'application/json', } data = '{"id":"bee62419-016f-1000-f131-5c589af8faff","state":"RUNNING"}' response = requests.put('http://localhost:8080/nifi-api/flow/process-groups/bee62419-016f-1000-f131-5c589af8faff', headers=headers, data=data)
... View more
01-20-2020
11:10 PM
I'm trying to execute python code to start processor group and getting below error
Error:
Traceback (most recent call last): 400 Client Error: Bad Request for url: http://localhost:8080/nifi-api/process-groups/bee62419-016f-1000-f131-5c589af8faff File "/Users/xxxx/Documents/Project/BU/pythonPractice/nifiTest.py", line 19, in <module> r.raise_for_status() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://localhost:8080/nifi-api/process-groups/bee62419-016f-1000-f131-5c589af8faff
Code:
newUrl="http://localhost:8080/nifi-api/process-groups/bee62419-016f-1000-f131-5c589af8faff" data1={'id':'bee62419-016f-1000-f131-5c589af8faff','state':'RUNNING'} try: r = requests.put(newUrl, data=data1,headers={'Content-Type': 'application/json','Accept': 'application/json','Authorization': 'Bearer [OAUTH2_TOKEN]'}) #r = requests.get(newUrl, data=data1, headers={'Content-Type': 'application/json', 'Accept': 'application/json', # 'Accept-Charset': 'UTF-8'}) r.raise_for_status() except requests.exceptions.RequestException as e: print(e) raise
When same thing I'm executing through curl command it working for me
curl -i -X PUT -H "Content-Type: application/json" -d '{"id":"bee62419-016f-1000-f131-5c589af8faff","state":"RUNNING"}' http://localhost:8080/nifi-api/flow/process-groups/bee62419-016f-1000-f131-5c589af8faff HTTP/1.1 200 OK Date: Mon, 20 Jan 2020 16:38:34 GMT X-Frame-Options: SAMEORIGIN Content-Security-Policy: frame-ancestors 'self' X-XSS-Protection: 1; mode=block Cache-Control: private, no-cache, no-store, no-transform Content-Type: application/json Vary: Accept-Encoding Vary: User-Agent Content-Length: 63 Server: Jetty(9.4.19.v20190610)
... View more
Labels:
- Labels:
-
Apache NiFi