nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Gilman <matt.c.gil...@gmail.com>
Subject Re: using rest api to enable transmission in remote process group
Date Thu, 25 May 2017 15:06:50 GMT
Mohammed,

I would guess that the request failed and the response body contains an
error message and you're attempting to parse that as JSON. I'd suggest
inspecting the response codes from the request before attempting to
interpret the response body. You can also look at your logs/nifi-user.log
for any errors from your request.

Thanks

Matt

On Thu, May 25, 2017 at 10:04 AM, mohammed shambakey <shambakey1@gmail.com>
wrote:

> Hi
>
> I'm trying to call nifi rest api from Python "request" module (
> http://docs.python-requests.org/en/master/) to enable transmission in a
> remote process group (I think this is done by changing the "transmitting"
> element in the required input port to a boolean "true").
>
> So, I get the JSON file of the remote process group using this Python
> "requests" module commad:
>
> rpg=requests.get("http://localhost:8085/nifi-api/remote-process-groups/<id
> of remote process group>").json()
> The output json file is attached
>
> I modified the "transmitting" element of the the input port to boolean
> "True", then, I tried to pass the modified JSON file to the following
> command
>
> rpg_new=requests.put("http://localhost:8085/nifi-api/
> remote-process-groups/<id of remote process group>", json=rpg).json()
>
> But I receive the following error:
> "
> Traceback (most recent call last):
>   File "rpg_nifi_create.py", line 116, in <module>
>     rpg_update=requests.put(url_rpg_update+rpg['id'],json=rpg,
> headers=token_header).json()
>   File "/home/shambakey1/miniconda2/lib/python2.7/site-packages/requests/models.py",
> line 826, in json
>     return complexjson.loads(self.text, **kwargs)
>   File "/home/shambakey1/miniconda2/lib/python2.7/json/__init__.py", line
> 339, in loads
>     return _default_decoder.decode(s)
>   File "/home/shambakey1/miniconda2/lib/python2.7/json/decoder.py", line
> 367, in decode
>     raise ValueError(errmsg("Extra data", s, end, len(s)))
> ValueError: Extra data: line 1 column 2 - line 1 column 63 (char 1 - 62)
> "
>
> I tried to truncate the passed JSON file such that it contains information
> only about "revision" and the modified "inputPorts" list, but still the
> same problem.
>
> I can the JSON file (before and after modification) using jsonview, so I
> think there is nothing wrong the JSON structure (e.g., no independent
> dictionaries). I don't know what is the problem?
>
> Regards
>
> --
> Mohammed
>

Mime
View raw message