I'm using the new shiny Google Spreadsheet API v4 in Python on a server. I 
am able to create a new spreadsheet, but ignores the name I pass it. 
Instead, it creates a spreadsheet by the name of "Untitled spreadsheet".

storage = Storage(GoogleCredentialsModel, 'id', request.user, 'credential')
    credential_obj = storage.get()
    if credential_obj is None or credential_obj.invalid == True:
        FLOW.params['state'] = xsrfutil.generate_token(settings.SECRET_KEY, 
request.user)
        authorize_url = FLOW.step1_get_authorize_url()
        #FLOW.params.update({'redirect_uri_after_step2': 
"/export_new_gsheet/%s/" % id})
        request.session['redirect_uri_after_step2'] = 
"/export_new_gsheet/%s/" % id
        return HttpResponseRedirect(authorize_url)
    credential = json.loads(credential_obj.to_json())

    http = credential_obj.authorize(httplib2.Http())
    discoveryUrl = ('https://sheets.googleapis.com/$discovery/rest?'
                    'version=v4')
    service = discovery.build('sheets', 'v4', http=http,
                              discoveryServiceUrl=discoveryUrl)

    post_body =  {"resource": {
        "properties": {
            "title": "XYZ Sheet",
        },
        "sheets": [
            {
                "properties": {
                    "title": "MySHEEET",
                }
            }
        ]
    }}
    headers = {'Content-type': 'application/x-www-form-urlencoded'}
    res, content = 
http.request("https://sheets.googleapis.com/v4/spreadsheets";,
                                method = "POST",
                                body=urllib.urlencode(post_body),
                                headers = headers)
    return JsonResponse({"res": res, "content": content})

 Any ideas?



-- 
You received this message because you are subscribed to the Google Groups 
"Google Spreadsheets API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to