Google API Get event - Not Found - google-api

I am trying to to get event resource using the following api
https://www.googleapis.com/calendar/v3/calendars/primary/events/eventId.
However, I am receiving 404 Not Found response, eventId is correct, I've checked it many times. Also, I've tried to call same method from their website (https://developers.google.com/calendar/api/v3/reference/events/get) and still receiving same error. You can find the attached screenshot here.
API Response Body :
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}

404 Not Found means just that not found.
The event.get method takes a event id as a parameter.
The user you are authencation with needs to have permission to access that event your its going to return a 404 not found for that user.
Try doing an events.list first for the calendar to get a list of all valid events for that calendar if it also returns a 404 then the problem would be that the user does not have access to that calendar.

Related

What is the meaning of Google Calendar API Delete 410 error

I'm trying to delete an event from one of my Google calendars using the Java API. They code looks like:
calendarService.events().delete( calendarId , eventId ).execute();
When I do so, I get the error:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 410 Gone
DELETE https://www.googleapis.com/calendar/v3/calendars/xxxxxxxxxxxxxxxxxxx#group.calendar.google.com/events/jm1gamo1cj3dm68bidsaufffdg
{
"code" : 410,
"errors" : [ {
"domain" : "global",
"message" : "Resource has been deleted",
"reason" : "deleted"
} ],
"message" : "Resource has been deleted"
}
I can't figure out what the message is telling me.
Is it saying the event wasn't found? If so, the wording seems odd - why wouldn't it say "not found".
Or, is it saying it was deleted previously where the event is marked as deleted (a logical deletion) but still remains in the system (thus it knows it was previously deleted) possibly queued for a physical deletion?
According to the Calendar API documentation here:
410: Gone
SyncToken or updatedMin parameters are no longer valid. This error can also occur if a request attempts to delete an event that has already been deleted.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "deleted",
"message": "Resource has been deleted"
}
],
"code": 410,
"message": "Resource has been deleted"
}
}
So, if you already deleted an event and you try to delete it again, you will most likely be getting this error message.
Reference
Calendar API Handling API Errors.

What does a 404 mean in the context of a Google Calendar API?

I am trying to programatically access a calendar I own using the Google Calendar API list:
r = requests.get(
url="https://www.googleapis.com/calendar/v3/calendars/<the ID of my calendar which looks like mydomain_randomstuff#group.calendar.google.com>/events",
params={
'key': <the key from the API console>,
'singleEvents': True,
'orderBy': 'startTime'
}
This call fails with a 404:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
What does that error actually mean, in the context of this API?
Note:
the calendar does exist and it has events
the API limits are not even close to be reached
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
Can mean one of two things. Either the calendar Id you have typed is in correct or the user who you are authenticated with does not have access to that calendar. Make sure you are logging in with the correct user with access to that calendar. Optionally you can do a calendar.list which will return a list of the calendars that the user currently has access to. That way you wont have to worry about possibly miss typing the calendar id.
authorization
The method you are using events.list requires authorization (permission from the user) in order to access their calendar. Which can be seen in the documentation page
You need to authncate your user using Oauth2 and one of the scopes above. You will then have an access token you can use to access this calendar.
apikey
Api keys are used for accessing public data. Unless your calendar is set to public you will not be able to use it to see events. Also remember that api keys do not have access to update public calendars you still need to be authenticated to make changes to them.
Service account
If this is a server to server application you should use a service account not an API key. All you need to do is add the service account as a user on the google calendar like you would any other user. It will then have access to your calendar.

Youtube Data API v3 nextPageToken not working

So I've just started to use the Youtube Data API to get comments from youtube videos. My program has been working until I tried to use the next page token to get more comments. So it first calls the normal URL without the &pageToken=***and then the next time it loops back it calls it with that but returns an error
{
"error": {
"errors": [
{
"domain": "youtube.parameter",
"reason": "invalidPageToken",
"message": "The request specifies an invalid page token.",
"locationType": "parameter",
"location": "pageToken"
}
],
"code": 400,
"message": "The request specifies an invalid page token."
}
}
My program, when calling the first time would get the key returned and save it in a variable for the next time it calls the new url. Yes, I have verified that my variable holds a key. Any help would be greatly appreciated! Thanks in advance :D
You forget playlistId it's required , example :
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=3&playlistId=PLw6Y5u47CYq47oDw63bMqkq06fjuoK_GJ&pageToken=EAAaBlBUOkNBTQ&key=['api_key']&nextPageToken=EAAaBlBUOkNBTQ
take a look on api documentation

youtube.liveChatMessages.list API Explorer

I try list messages from LiveChat of YouTube. Request:
GET https://www.googleapis.com/youtube/v3/liveChat/messages?liveChatId=Qfad59EnhUA&part=snippet&key={YOUR_API_KEY}
Response:
404 Not Found
{
"error": {
"errors": [
{
"domain": "youtube.liveChat",
"reason": "liveChatNotFound",
"message": "The live chat that you are trying to retrieve cannot be found. Check the value of the requests <code>liveChatId</code> parameter to ensure that it is correct."
}
],
"code": 404,
"message": "The live chat that you are trying to retrieve cannot be found. Check the value of the requests <code>liveChatId</code> parameter to ensure that it is correct."
}
}
Pages https://www.youtube.com/live_chat?is_popout=1&v=Qfad59EnhUA and
https://www.youtube.com/watch?v=Qfad59EnhUA exist.
What's wrong?
i decide this problem. liveChatId can be get from broadcast for python:
print '%s' % (broadcast['snippet']['liveChatId'])

user.messages.get responding invalid ID

when attempting to test out the api explorer for user.messages: get I have been getting an invalid message ID response.
I am getting the message ID from a recent email in my inbox sent to me, and removed the <> from either ends.
response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Invalid id value"
}
],
"code": 400,
"message": "Invalid id value"
}
}
I am a bit confused as I am using the powershell module gshell and noticed that the same messageID worked in my commands but returned invalid id value in the api explorer.
edit: if I do a inbox search for rfc822msgid:[messageID] it returns the correct message
First you have to call the users.messages.list api. It will give a list of messageids. Then we have to call users.message.get api with each messageid to fetch the mail content. You can query the mails with advanced search options provided by Gmail API.
You should not use the rfc822msgid, but the Gmail API message id. Try to list messages and use the id you get from that when getting the message.

Resources