Drewster727 / tautulli-influxdb-export

Export Tautulli (formerly PlexPy) stats to InfluxDB
69 stars 15 forks source link

No JSON object could be decoded #15

Open vixfix opened 5 years ago

vixfix commented 5 years ago

getting a return of No JSON object could be decoded i know im missing something simple

Twiggy-GH commented 3 years ago

I'm also getting this issue after using the script without issue for over a year.

Twiggy-GH commented 3 years ago

Is this script abandoned? I'm once again getting this error and having difficulty troubleshooting it.

bobarune commented 3 years ago

@Twiggy-GH Is there any stack trace with that error? Or line number?

Based on the "No JSON object could be decoded", I suspect it could be one of the calls to the Tautulli API is returning invalid JSON. Maybe it's partially valid and the default parser of the requests module is possibly more strict. Another possibility is the tautulli API is erroring in some way eg. returning a 500 and the returned text isn't json.

Could you try running the following calls and running a JSON validator on each return results? No need to post the JSON return results here as it's full of information you would want to remove. I'm making an assumption that you might be using http. Default port should be 8181. You can just throw these in your browser since it is a GET request.

http://<tautulli ip or hostname>:<tautulli port>/api/v2?apikey=<tautulli API Key>&cmd=get_users
http://<tautulli ip or hostname>:<tautulli port>/api/v2?apikey=<tautulli API Key>&cmd=get_activity
http://<tautulli ip or hostname>:<tautulli port>/api/v2?apikey=<tautulli API Key>&cmd=get_libraries

Edit: As an example, one of mine would be http://monitor-pi:8181/api/v2?apikey=SuperSecretApiKey&cmd=get_users . In this case, my hostname is monitor-pi and my port is 8181 and my API key is SuperSecretApiKey (Not actually)

Another thing you could try is to fully test the JSON decoding calls with your setup using the following python script:

#!/usr/bin/python

import os
import time
import requests

def main():
    data1 = requests.get('http://<tautulli ip or hostname>:<tautulli port>/api/v2?apikey=<tautulli API Key>&cmd=get_users', verify=False).json()
    data2 = requests.get('http://<tautulli ip or hostname>:<tautulli port>/api/v2?apikey=<tautulli API Key>&cmd=get_activity', verify=False).json()
    data3 = requests.get('http://<tautulli ip or hostname>:<tautulli port>/api/v2?apikey=<tautulli API Key>&cmd=get_libraries', verify=False).json()
    print(data1)
    print(data2)
    print(data3)

if __name__ == '__main__':
    main()

You will have to pip install 'requests' since it is a third party module.

And to get you Tautulli API Key, go to Settings -> Web Interface and scroll to the bottom. However you are running this exporter, make sure you have the right Tautulli API Key.