how to get specific items data from google calendar api - google-calendar-api

hi I am using google api to get all the events which is working fine. There is a parameter where I can specify fields name which I need to retrieve. There is a filed named as items where all the events data are coming. Now I want to get specific data of that items filed. Not all the data.
This is how I am getting all the data of that items.
https://www.googleapis.com/calendar/v3/calendars/CALENDAR_ID/events?showDeleted=true&timeMax=2021-08-16T06%3A00%3A46.000Z&timeMin=2021-04-16T06%3A00%3A46.000Z&prettyPrint=true&fields=items&key=[YOUR_API_KEY]
This is how data are coming.
{
"items": [
{
"kind": "calendar#event",
"etag": "\"hfsfjadj\"",
"id": "adfjadfjad",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=adfjdafjd",
"created": "2021-05-24T05:47:42.000Z",
"updated": "2021-05-24T05:47:42.331Z",
"summary": "dafhafj",
"creator": {
"email": "adfjadfj#gmail.com",
"self": true
},
"organizer": {
"email": "adfjadfj#gmail.com",
"self": true
},
"start": {
"dateTime": "2021-05-24T11:30:00+06:00"
},
"end": {
"dateTime": "2021-05-24T12:30:00+06:00"
},
"iCalUID": "dfjdfjdfj#google.com",
"sequence": 0,
"reminders": {
"useDefault": true
},
"eventType": "default"
}
]
}
I wanted to fetch only id, start,end and summary not the entire thing which is given above.

You can specify nested fields by enclosing them in round brackets, and multiple fields should be separated by commas. Your provided fields would be something like this:
items(id,start,end,summary)
Therefore, the URL would change from this:
https://www.googleapis.com/calendar/v3/calendars/CALENDAR_ID/events?showDeleted=true&timeMax=2021-08-16T06%3A00%3A46.000Z&timeMin=2021-04-16T06%3A00%3A46.000Z&prettyPrint=true&fields=items&key=[YOUR_API_KEY]
To this:
https://www.googleapis.com/calendar/v3/calendars/CALENDAR_ID/events?showDeleted=true&timeMax=2021-08-16T06%3A00%3A46.000Z&timeMin=2021-04-16T06%3A00%3A46.000Z&prettyPrint=true&fields=items(id%2Cstart%2Cend%2Csummary)&key=[YOUR_API_KEY]
Reference:
Partial response

Related

How to send event parameters for a tag through the google tag manager API

With this query i can create a GTM event tag for Google Analytics 4. i would like to pass some event parameters aswell. I feel that im really close because the API seems to recognize the eventParameters key, it tells me that its value its invalid.
"vendorTemplate.parameter.eventParameters[0]: The value is invalid.\n",
If i change this eventParameters key to something else, the query goes through (obviously without taking into consideration my eventParameters) so i know that this code has to be close.
The documentation is really shallow so building queries with the GTM api its been very trial and error until now.
When i get this working i'll probably make a sample for automating trigger and tag creation for GA4 migrations
`
{
"name": "test2",
"type": "gaawe",
"parameter": [
{
"type": "template",
"key": "eventName",
"value": "hey"
},
{
"type": "tagReference",
"value": "LocalTag",
"key": "measurementId"
},
{
"type": "list",
"key": "eventParameters",
"list": [
{
"type": "template",
"value": "page_title",
"key": "page_title"
}
]
}
]
}
`
The parameters is a array
Here is the example:
{
"type": "MAP",
"map": [
{
"type": "TEMPLATE",
"key": "name",
"value": `${parameterName}`
},
{
"type": "TEMPLATE",
"key": "value",
"value": `${parameterValue}`
}
]
}
And if you want to pass a variable to the value
Just add the "{{" , "}}" as you used in GTM UI.
Like {{DataLayer-Ecommerce}}
So yes you are very close to it.

Searching Google Calendar extendedProperties does not return any match

I am using Google Calendar API v3 in to search for a specific property/value. I was able to successfully create the extended property as you can see here:
{
"kind": "calendar#events",
"etag": "\"p33cf16d5ousve0g\"",
"summary": "Ryan's Personal Camptivities",
"updated": "2022-04-29T15:11:23.687Z",
"timeZone": "America/Los_Angeles",
"accessRole": "owner",
"defaultReminders": [
{
"method": "popup",
"minutes": 10
}
],
"nextSyncToken": "CNjwmaXHufcCENjwmaXHufcCGAUg67Ly0wE=",
"items": [
{
"extendedProperties": {
"private": {
"OutlookEventGO": "AAMkADNkODYzZGQ5LWY5ZGItNGFjZi1iMWMzLTI3MmY0YmIxMTcxNQBGAAAAAAC5E322QQ7ORLEmN7zGNq0zBwAUl432Bg61QItQhHQwcosuAAAAAAENAAAUl432Bg61QItQhHQwcosuAAF6QI0zAAA="
}
]
}
but when I go to search for the extendedProperty, i get no response:
https://www.googleapis.com/calendar/v3/calendars/ryan%40camptivities.com/events?privateExtendedProperty=OutlookEventGO%3DAAMkADNkODYzZGQ5LWY5ZGItNGFjZi1iMWMzLTI3MmY0YmIxMTcxNQBGAAAAAAC5E322QQ7ORLEmN7zGNq0zBwAUl432Bg61QItQhHQwcosuAAAAAAENAAAUl432Bg61QItQhHQwcosuAAF6QI0zAAA%3D&
{
"kind": "calendar#events",
"etag": "\"p33cf16d5ousve0g\"",
"summary": "Ryan's Personal Camptivities",
"updated": "2022-04-29T15:11:23.687Z",
"timeZone": "America/Los_Angeles",
"accessRole": "owner",
"defaultReminders": [
{
"method": "popup",
"minutes": 10
}
],
"nextSyncToken": "CNjwmaXHufcCENjwmaXHufcCGAUg67Ly0wE=",
"items": []
}
Is this because of the encoding of the extendedProperty value? If so, how do I fix this? If not, what am I doing wrong?
Thanks in advance...
The problem is the = at the end of your privateExtendedProperty value
This seems to create issues when it comes to the url encoding of the property.
If you use a property value without an =, e.g.
AAMkADNkODYzZGQ5LWY5ZGItNGFjZi1iMWMzLTI3MmY0YmIxMTcxNQBGAAAAAAC5E322QQ7ORLEmN7zGNq0zBwAUl432Bg61QItQhHQwcosuAAAAAAENAAAUl432Bg61QItQhHQwcosuAAF6QI0zAAA
you can perfectly retrieve it with out request:
https://www.googleapis.com/calendar/v3/calendars/ryan%40camptivities.com/events?privateExtendedProperty=OutlookEventGO%3DAAMkADNkODYzZGQ5LWY5ZGItNGFjZi1iMWMzLTI3MmY0YmIxMTcxNQBGAAAAAAC5E322QQ7ORLEmN7zGNq0zBwAUl432Bg61QItQhHQwcosuAAAAAAENAAAUl432Bg61QItQhHQwcosuAAF6QI0zAAA
Your privateExtendedProperty seems to be encoded, so if the = is important for you to decode the value back, you will need to add it back programatically when require.

Logic App > Cosmos PartitionKey Not Matching Error

I'm scared to put this out there because it should be so easy and I am facing the same issue as the post here, here and here and I have tried each of the answers to no avail. Below is the current Resulting Input (redacted) and Related CodeView of the inputs.
The Result
{
"method": "post",
"headers": {
"x-ms-documentdb-raw-partitionkey": "\"2020\""
},
"path": "/dbs/xxxx/colls/smtp/docs",
"host": {
"connection": {
"name": "/subscriptions/..."
}
},
"body": {
"category": [
[
"cat facts"
]
],
"email": "example#test.com",
"event": "processed",
"id": "yada",
"partitionKey": "\"2020\"",
"sg_event_id": "yada yada",
"sg_message_id": "yada",
"smtp-id": "yada",
"timestamp": 1604345542
}
}
The Code View
{
"inputs": {
"body": {
"category": [
"#items('For_each')['category']"
],
"email": "#items('For_each')['email']",
"event": "#items('For_each')['event']",
"id": "#items('For_each')['sg_message_id']",
"partitionKey": "\"#{formatDateTime(utcNow(),'yyyy')}\"",
"sg_event_id": "#items('For_each')['sg_event_id']",
"sg_message_id": "#items('For_each')['sg_message_id']",
"smtp-id": "#items('For_each')['smtp-id']",
"timestamp": "#items('For_each')['timestamp']"
},
"headers": {
"x-ms-documentdb-raw-partitionkey": "\"#{formatDateTime(utcNow(),'yyyy')}\""
}
}
The error I'm getting is the usual one - PartitionKey extracted from document doesn't match the one specified in the header
I just can't see what I'm missing here now.
Thanks all.
First, as Matias comments, check your partition key path.
Then, change this code "partitionKey": "\"#{formatDateTime(utcNow(),'yyyy')}\"", to "partitionKey": "#{formatDateTime(utcNow(),'yyyy')}", in your document.
It works fine on my side:

JSONAPI - Difference between self and related in a links resource

Why is the self and related references different in the below JSONAPI resource? Aren't they pointing to the same resource? What is the difference between going to /articles/1/relationships/tags and /articles/1/tags?
{
"links": {
"self": "/articles/1/relationships/tags",
"related": "/articles/1/tags"
},
"data": [
{ "type": "tags", "id": "2" },
{ "type": "tags", "id": "3" }
]
}
You can read about that here: https://github.com/json-api/json-api/issues/508.
Basically, with /articles/1/relationships/tags response will be object which represents relationship between articles and tags. The response could be something like this (what you put in your question):
{
"links": {
"self": "/articles/1/relationships/tags",
"related": "/articles/1/tags"
},
"data": [
{ "type": "tags", "id": "2" },
{ "type": "tags", "id": "3" }
]
}
This response gives only the necessary data (in primary data attribute - data) to manipulate the relationship and not resources connected with relationship. That being said, you'll call /articles/1/relationships/tags if you want to create new relationship, add a new tag (basically updating relationship) to article, read which tags belong to article (you only need identity to search them on server) or delete article tags.
On the other hand, calling /articles/1/tags will respond with tags as primary data with all the other properties that they have (articles, relationships, links, and other top-level attributes such include, emphasized text, links and/or jsonapi).
They are different. Here is an example from my project.
Try Get http://localhost:3000/phone-numbers/1/relationships/contact you will get response like this:
{
"links": {
"self": "http://localhost:3000/phone-numbers/1/relationships/contact",
"related": "http://localhost:3000/phone-numbers/1/contact"
},
"data": {
"type": "contacts",
"id": "1"
}
}
You didn't get the attributes and relationships which is probably you want to retrieve.
Then
Try Get http://localhost:3000/phone-numbers/1/contact you will get response like this:
{
"data": {
"id": "1",
"type": "contacts",
"links": {
"self": "http://localhost:3000/contacts/1"
},
"attributes": {
"name-first": "John",
"name-last": "Doe",
"email": "john.doe#boring.test",
"twitter": null
},
"relationships": {
"phone-numbers": {
"links": {
"self": "http://localhost:3000/contacts/1/relationships/phone-numbers",
"related": "http://localhost:3000/contacts/1/phone-numbers"
}
}
}
}
}
You can see you retrieved all the information you want, including the attributes and relationships.
But you should know that relationships can be used for some purpose. Please read http://jsonapi.org/format/#crud-updating-to-one-relationships as a sample.

Google Calendar Events after 7pm are not retrieved until the Next Day using Google Events API

I've updated this because this question makes more sense than the original. I'm still including the test code that I used to show what's happening.
Please see the comments for more up to date information on what I've found.
Executed API to grab events for today (there should be 1):
/calendar/v3/calendars/{calid}/events?calendarId={calid}&singleEvents=true&timeMin=2013-04-24T00:00:00.000Z&timeMax=2013-04-25T00:00:00.000Z
It retrieves nothing. No events are returned.
If I execute the following (ie, the next day):
/calendar/v3/calendars/{calid}/events?calendarId={calid}&singleEvents=true&timeMin=2013-04-25T00:00:00.000Z&timeMax=2013-04-26T00:00:00.000Z
It retrieves the following which is set for the 24th (yet after 7pm), not the 25th:
{
"kind": "calendar#events",
"etag": "\"GZxpEFttRDAOmLHnWRxLHHWPGwk/01XVNYQjwJ5jTmd05uIgK9e6Uhw\"",
"summary": "test calendar",
"description": "test calendar",
"updated": "2013-04-24T13:09:12.000Z",
"timeZone": "America/Chicago",
"items": [
{
"kind": "calendar#event",
"etag": "\"GZxpEFttRDAOmLHnWRxLHHWPGwk/Z2NhbDAwMDAxMzY2MTQ4ODczODI3MDAw\"",
"id": "d1mdj3dasor22f0nm0lbohru7s",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=ZDFtZGozZGFzb3IyMmYwbm0wbGJvaHJ1N3MgYnZzdG9vbHMuY29tX2xidWt1ZmlnczJjMmFycjViODgycDVhYWhvQGc",
"created": "2013-04-16T21:47:53.000Z",
"updated": "2013-04-16T21:47:53.827Z",
"summary": "this should happen 4/24/2013",
"description": "testing event",
"creator": {
"email": "{my email address}",
"displayName": "my name"
},
"organizer": {
"email": "{calid}",
"displayName": "test calendar",
"self": true
},
"start": {
"dateTime": "2013-04-24T21:21:19-05:00"
},
"end": {
"dateTime": "2013-04-24T21:21:19-05:00"
},
"iCalUID": "d1mdj3dasor22f0nm0lbohru7s#google.com",
"sequence": 0,
"extendedProperties": {
"private": {
"evtKey": "key"
}
},
"reminders": {
"useDefault": true
}
}
]
}
It should be retrieving it for the first api call on the 24th, not the 2nd api call on the 25th unless I'm missing something.
Any ideas? Thanks!
a bit late but if you still needs it. I think the event you retrieved d1mdj3dasor22f0nm0lbohru7 seems to be in default timezone of the calendar, which is America/Chicago. That explains why it only showed when you set your query to 25th UTC time

Resources