GrandyB / SheetsIO

Small configurable Java app that pulls data from a Google Spreadsheet (using v4 api) and writes to files and a local webserver.
GNU Lesser General Public License v3.0
22 stars 3 forks source link

worksheetName doesn't accept space or dash in string #40

Closed hao24real closed 3 years ago

hao24real commented 3 years ago

Describe the bug If the name of the tab include dash or space, SheetsIO will throw an error after clicking "update now"

To Reproduce Steps to reproduce the behavior:

  1. Go to json file
  2. Change worksheetName into any name containing space or dash
  3. save json and load the config SheetsIO, then click Update now

Expected behavior Should run smoothly regardless of space of dash

Screenshots if containing space, it throws json error which is not correct, because space is acceptable in json Screenshot 2021-04-02 174750

if containing dash it says unable to parse range image

Desktop (please complete the following information):

GrandyB commented 3 years ago

Nice catch! I'll have a look at that now.

GrandyB commented 3 years ago

So the two errors... When SheetsIO requests data from the Google Sheets API it needs the spreadsheet ID, worksheet name and the apiKey; you can also optionally provide it a cell reference "range" (e.g. A4:D4) and only return data from those cells, but SheetsIO just asks for the whole sheet.

Previously, we were taking the worksheet name from config and directly putting it into the URL for the request to Google... but spaces are not automatically handled - we have to do some encoding ourselves to replace " " with "%20", otherwise Google returns a html page giving a vague explanation that a bad request happened. So there's two parts to this - one is that SheetsIO needs to "nicely" handle when json is not returned so that the error is more informative, and we need to properly encode the worksheet name when making a request.

I am currently putting together a new minor version release (v0.7.2) - will add tests for the fix here and release that shortly.

GrandyB commented 3 years ago

Addressed in https://github.com/GrandyB/SheetsIO/commit/f80438133f9bf5ebb32530b230384ff42c10bc49

GrandyB commented 3 years ago

Released in v0.7.2

https://github.com/GrandyB/SheetsIO/releases/tag/v0.7.2