You appear to be mixing two things, “the gviz private sheet query”, and “a doGet(e) submit data to a spreadsheet”.
These require different approaches. it may be easier to have a different web app for each, then you do not have to run any if tests in the web app (if query then, else submit) and send additional parameters from the app for this.
You may be OK if you use doGet(e) for the query and doPost(e) for the submit though…