Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discovery is urlencoding google_api and causing 404 not found #838

Closed
mvfpoa opened this issue Mar 11, 2020 · 3 comments
Closed

discovery is urlencoding google_api and causing 404 not found #838

mvfpoa opened this issue Mar 11, 2020 · 3 comments
Assignees
Labels
api: calendar Issues related to the Calendar API API. type: question Request for information or clarification. Not an issue.

Comments

@mvfpoa
Copy link

mvfpoa commented Mar 11, 2020

Hi,

When I try to create an event, the url become encoded: calendarId changes from some@calendar.com to some%40calendar.com. Google reports 404.

Environment details

Ubuntu DiscoDingo
Python 3.7.3
pip 20.0.2
google-api-python-client==1.7.12
httplib2==0.17.0

Steps to reproduce

  1. run the following code:
import google.auth
from googleapiclient.discovery import build

SCOPES=['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/gmail.send']

cred, _ = google.auth.default(scopes=SCOPES)

cred = cred.with_subject('my@domain.com')

service = build('calendar', 'v3', credentials=cred)

body = {'attendees': None, 
        'end': {'dateTime': '2020-03-20T09:30:00+00:00'}, 
        'extendedProperties': {'private': None}, 
        'id': '123123', 
        'location': None, 
        'privateCopy': False, 
        'start': {'dateTime': '2020-03-20T08:00:00+00:00'}, 
        'summary': 'Ensaio', 
        'transparency': 'opaque'}

print(service.events().insert(calendarId='teste@test.com', body=body, sendUpdates='externalOnly').execute())
  1. expect to see google api response, but the following message comes:

venv/lib/python3.7/site-packages/googleapiclient/http.py", line 898, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 404 when requesting https://www.googleapis.com/calendar/v3/calendars/teste%40test.com/events?sendUpdates=externalOnly&alt=json returned "Not Found">

Thanks!

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Mar 12, 2020
@busunkim96
Copy link
Contributor

busunkim96 commented Mar 17, 2020

Hi @mvfpoa, the url encoding is working as intended (the http request would be invalid otherwise). Can you confirm that the credentials you are using have permissions to that calendar? You will get a 404 if the credentials don't have sufficient permissions.

@busunkim96 busunkim96 added api: calendar Issues related to the Calendar API API. type: question Request for information or clarification. Not an issue. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Mar 17, 2020
@busunkim96 busunkim96 self-assigned this Mar 17, 2020
@mvfpoa
Copy link
Author

mvfpoa commented Mar 18, 2020

Instead of using discovery, I am using print(AuthorizedSession(cred).post("https://www.googleapis.com/calendar/v3/calendars/teste@test.com/events?sendUpdates=externalOnly&alt=json", json=body)) and it works flawlessly.
Is there any other library dependency which might be involved in my particular problem, so we can check versions?

@mvfpoa
Copy link
Author

mvfpoa commented Mar 18, 2020

I decided to have a shot again in the sample code and the returning error changed completely. Now it says 409 "The requested identifier already exists.". I removed my custom Id from json, and the event was created as expected. I think the problem was solved some other way, and was related to the short id i was trying to create.
I am marking it closed for instance.

@mvfpoa mvfpoa closed this as completed Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: calendar Issues related to the Calendar API API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants