Menu

JSON decode problem

2015-12-15
2016-02-26
  • Gyorgy Rath

    Gyorgy Rath - 2015-12-15

    Hi,
    From today the file uploads give an error for me. The workout appears in Garmin Connect but its name is Untitled.
    I use Python 2.7.10 and 2.7.11 on Arch Linux.
    I get the following messages:

    Traceback (most recent call last):
      File "/usr/bin/gupload.py", line 401, in <module>
        g.gupload()
      File "/usr/bin/gupload.py", line 248, in gupload
        status, id_msg = g.upload_file(workout.filename)
      File "/usr/lib/python2.7/site-packages/UploadGarmin.py", line 275, in upload_file
        res = res.json()["detailedImportResult"]
      File "/usr/lib/python2.7/site-packages/requests/models.py", line 805, in json
        return complexjson.loads(self.text, **kwargs)
      File "/usr/lib/python2.7/site-packages/simplejson/__init__.py", line 516, in loads
        return _default_decoder.decode(s)
      File "/usr/lib/python2.7/site-packages/simplejson/decoder.py", line 370, in decode
        obj, end = self.raw_decode(s)
      File "/usr/lib/python2.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
        return self.scan_once(s, idx=_w(s, idx).end())
    simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    Failed to upload: 1
    

    I recently made an OS upgrade which might be related to the issue. The following packages were upgraded:
    python-urllib3 (1.12-3 -> 1.13-1)
    python-xcffib (0.4.0-1 -> 0.4.0-2)
    python2 (2.7.10-2 -> 2.7.11-1)
    python2-setuptools (1:18.5-1 -> 1:18.8.1-1)

    I downgraded back to the former versions but no luck, same error message.

    Can anyone help, pls?

     

    Last edit: Gyorgy Rath 2015-12-15
  • Gyorgy Rath

    Gyorgy Rath - 2015-12-23

    No one experiencing this?

     
  • Dave Lotton

    Dave Lotton - 2015-12-23

    Hi Gyorgy,

    Sorry, my time to support this program is extremely limited at this time. One thing you might try is open the file UploadGarmin.py and comment out the following block of code....

    try:
        import simplejson
    except ImportError:
        import json as simplejson
    

    ....and replace it with this...

    import json as simplejson
    

    I have my doubts that this will help, but it is worth trying. It sounds like Garmin may have changed the way their web API works, which could take a considerable amount of time to debug.

     
  • Frank Crawford

    Frank Crawford - 2015-12-31

    I'm also experiencing this issue, although the files are still uploaded to the Garmin site, so I suspect it is in the final part of the upload.

     
  • Frank Crawford

    Frank Crawford - 2015-12-31

    Also, the information from the last frame may help:

    :Local variables in innermost frame:
    :_w: <built-in method match of _sre.SRE_Pattern object at 0x7fe96e5c80d0>
    :s: u'<html><head><title>JBossWeb/2.0.0.GA - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/garmin/connect/activity/geoactivity/ActivityToGeoActivityInput</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/garmin/connect/activity/geoactivity/ActivityToGeoActivityInput</u></p><p><b>description</b> <u>The server encountered an internal error (java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/garmin/connect/activity/geoactivity/ActivityToGeoActivityInput) that prevented it from fulfilling this request.</u></p><HR size="1" noshade="noshade"><h3>JBossWeb/2.0.0.GA</h3></body></html>'
    :_PY3: False
    :idx: 0
    :self: <simplejson.decoder.JSONDecoder object at 0x7fe96e5d60d0>
    

    I'm not sure what Garmin's API is, but the complaint is that some URL you want does not exist.

     
  • Gyorgy Rath

    Gyorgy Rath - 2016-01-02

    import json as simplejson did not help.

    The activity is uploaded to Garmin but its name is always "Untitled", even if I use the -a argument to set the activity title. I believe, there is a code that downloads a json file from Garmin to determine the activity types accepted by Garmin and this json fails to be parsed.

     
  • Erik Rask

    Erik Rask - 2016-01-07

    This looks like Garmin have done changes in the server backend, some server postprocessing requires more input to convert an activity to a GeoActivity, whatever that is. The line that throws the exception is

    res = res.json()["detailedImportResult"]
    

    Because the result (pasted by Frank above) does not json encode properly. For now, I've commented that and the uses of res later and uploading still works. Setting names doesn't seem to work at all, I get a 500 (server error) and no effect on the workout.

     
    • Jens Oliver Müller

      Hi,
      iam trying to import more than 400 exported runtastic gpx file to garmin and getting the same error as Gyorgy Rath again.

      Could one perhaps lead me to the code that needs to commented so iam able to upload those files and do not have to use the garmin manual uploader for all 400 files?

      2016-02-26 13:01:02,687::__main__::DEBUG::Filename: D:\Downloads\runtastic\Laufe
      n\runtastic_20100802_1812_Laufen.gpx
      2016-02-26 13:01:02,687::__main__::DEBUG::File exists.
      2016-02-26 13:01:02,687::__main__::DEBUG::File Extension: .gpx
      2016-02-26 13:01:02,688::__main__::DEBUG::File 'D:\Downloads\runtastic\Laufen\ru
      ntastic_20100802_1812_Laufen.gpx' extension '.gpx' is valid.
      2016-02-26 13:01:03,723::UploadGarmin::INFO::Rate limited for 0.000000
      2016-02-26 13:01:05,063::UploadGarmin::INFO::Rate limited for 0.000000
      2016-02-26 13:01:06,062::UploadGarmin::INFO::Rate limited for 0.514000
      2016-02-26 13:01:06,654::__main__::INFO::Login Successful.
      2016-02-26 13:01:07,062::UploadGarmin::INFO::Rate limited for 0.408000
      Traceback (most recent call last):
        File "C:\Python27\Scripts\gupload.py", line 401, in <module>
          g.gupload()
        File "C:\Python27\Scripts\gupload.py", line 248, in gupload
          status, id_msg = g.upload_file(workout.filename)
        File "C:\Python27\lib\site-packages\UploadGarmin.py", line 275, in upload_file
      
          res = res.json()["detailedImportResult"]
        File "C:\Python27\lib\site-packages\requests\models.py", line 808, in json
          return complexjson.loads(self.text, **kwargs)
        File "C:\Python27\lib\site-packages\simplejson\__init__.py", line 516, in load
      s
          return _default_decoder.decode(s)
        File "C:\Python27\lib\site-packages\simplejson\decoder.py", line 370, in decod
      e
          obj, end = self.raw_decode(s)
        File "C:\Python27\lib\site-packages\simplejson\decoder.py", line 400, in raw_d
      ecode
          return self.scan_once(s, idx=_w(s, idx).end())
        File "C:\Python27\lib\site-packages\simplejson\scanner.py", line 127, in scan_
      once
          return _scan_once(string, idx)
        File "C:\Python27\lib\site-packages\simplejson\scanner.py", line 118, in _scan
      _once
          raise JSONDecodeError(errmsg, string, idx)
      simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
      

      Regards
      Jens

       
      • Gyorgy Rath

        Gyorgy Rath - 2016-02-26

        It works for me, no need to comment anything in the code. Although I use Linux and as I can see you have windows. It is possible that the json library in windows is broken but I am just guessing, I am far from being an expert.

         
  • Gyorgy Rath

    Gyorgy Rath - 2016-01-25

    They seem to have changed something at Garmin Connect. Uploading works again without any warning message, workout titles are also set correctly. Problem solved.

     

Log in to post a comment.