Working with one of my Google Apps users and a shared calendar he create suddenly disappeared. It was hidden (first thing we checked), but just gone. It is a number of steps to delete a calendar (for safety reasons) and it was certainly not deleted in this fashion.
Using the Google APIs Explorer for Calendar API v3 we do see a deleted calendar using calendar.calendarList.list when showDeleted is true. If we highlight that item in the JSON response the dropdown arrow on the top right of the item shows it can be used in calendar.calendarList.patch. Trying to remove the "deleted" flag results in a 404 resource not found. Copied the calendarId from the Patch JSON body up to the calendarId box, fields editor to show most all fields. Trying the same for calendar.calendars.patch we get the same result.
The OAuth scope is https://www.googleapis.com/auth/calendar. JSON body is
{
"kind": "calendar#calendarListEntry",
"etag": "\"XXXXXXXXXXXXXXXX\"",
"id": "XXXXXXXXXXXXXXXXXXXXXXXX#group.calendar.google.com",
"defaultReminders": [
],
"deleted": false
}
If a calendar is deleted from the CalendarList but you still know the id, you can add it back to the list with the insert endpoint.
Related
A Brief Overview of the Problem
I am trying to store JSON data on my SendGrid contacts for usage in dynamic email templates designed in the SendGrid GUI.
To start, within the SendGrid email builder I can write the following code within a codeblock:
Here is the handlebar code in that code block...
<ol>
{{#each user.accounts}}
{{#if this.isPending}}
<li>
{{this.name}} is <strong>pending activation.</strong>
</li>
{{else}}
<li>
{{this.name}} is <strong>active.</strong>
</li>
{{/if}}
{{/each}}
</ol>
When I go to preview that code & add some test data I get the following:
Here is the JSON code in that code block formatted a bit nicer...
{
"user": {
"accounts": [
{
"name": "Checking",
"isPending": false
},
{
"name": "401k",
"isPending": true
},
{
"name": "Savings",
"isPending": true
}
]
}
}
The Question
Everything mentioned above is PERFECT so far - this is exactly what I want... To populate email data based on dynamic content present on each contact the email is going to. Here is where I hit the roadblock, where is that JSON Test Data coming from on the contact when the real email is sent out? And how do I populate a contact with JSON data using the API?
As far as I can tell, there is no option to add this custom JSON data to a new contact when creating one via the API (or via the GUI, for that matter) (see API docs here)
When I set up this email to send out to my SendGrid contacts via a SendGrid automation flow, does anyone know how to populate the JSON used by my code block for showing pending/activated accounts with data specific to each user?
Thank you, I greatly appreciate any help on this!
I think that JSON data is actually only useful when you are using the API to send an email with a template. You then provide the JSON data as dynamic_template_data and it is populated in the email template.
When dealing with Automations, you need to pull the data from the contact record itself. You can get the data you have on a Contact in the Tags section of the template designer.
There are a number of fields that already exist on contacts, like first_name, last_name, email, address_line_1, etc. You can also add Custom Fields which give you further fields you can use on your contacts. Custom Fields can be created by adding new columns on an CSV upload of your contacts, by creating them in the SendGrid admin or by creating them via API.
If you are using the API to create or update your contacts, you can pass an object of custom_fields as part of the contact record in the API request. For example:
const data = {
"contacts": [
{
"email": "ryan39#lee-young.com",
"custom_fields": {
"w1": "2002-10-02T15:00:00Z",
"w33": 9.5,
"e2": "Coffee is a beverage that puts one to sleep when not drank."
}
}
]
};
Note that to set custom fields on a contact when you create/update by the API like this, you need to use the custom field ID as the key in the custom_fields object (like the example above, the IDs "w1", "w33" , "e2" were used). If you need to know those IDs, you can use the API to get all field definitions.
Once you have added Custom Fields they will also be available as Tags in the design editor, then you can use them in the email design.
The only thing is, I notice you are using an array of accounts in your example. If you need an array of arbitrary data, then I don't believe you can achieve that with contact data and automations. You can set individual custom fields for, say, a checking account, 401k and savings. But you cannot have arbitrary data in a custom field. If you really need the data to be arbitrary, then Automations might not be right for you and you should send your emails out using the send mail API and providing dynamic template data.
I'm trying to clear all the events of a google calendar using the calendar ID.
https://developers.google.com/resources/api-libraries/documentation/calendar/v3/python/latest/calendar_v3.calendars.html#clear
Attempting it, gives a "400 Bad Request" response from either Python or a simple curl call using the Google API Explorer:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value"
}
],
"code": 400,
"message": "Invalid Value"
}
}
From either the API explorer or the python API I'm providing only the calendar ID of the corresponding (non-primary) calendar I want to delete.
In Python:
service.calendars().clear(calendarId=<calid-found-in-calendarList().list()>).execute()
Which returns:
<HttpError 400 when requesting https://www.googleapis.com/calendar/v3/calendars/<calendar-id>4%40group.calendar.google.com/clear? returned "Invalid Value". Details: "[{'domain': 'global', 'reason': 'invalid', 'message': 'Invalid Value'}]">
Any idea what I'm doing wrong?
When I had tested the clear method of Calendars in Calendar API v3 before, I had experienced the same situation with you. When I used the value of primary, no error occurs. All events of the primary calendar are deleted. But, when I used the calendar ID except for the primary calendar, the same issue occurred.
When I saw the official document, it says Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.. But about calendarId in this method, it also says Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword..
These documents consuse me. So, I checked this "clear" method at Discovery API. Ref It says as follows.
"clear": {
"parameters": {
"calendarId": {
"location": "path",
"required": true,
"type": "string",
"description": "Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the \"primary\" keyword."
}
},
"scopes": [
"https://www.googleapis.com/auth/calendar"
],
"httpMethod": "POST",
"id": "calendar.calendars.clear",
"description": "Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.",
"parameterOrder": [
"calendarId"
],
"path": "calendars/{calendarId}/clear"
},
From above document, I thought that the calendar ID can be retrieved by the calendarList.list method. But, this "clear" method might not be able to be used for the calendar except for the primary calendar.
And, when I saw the error message, when the calendar ID like ####group.calendar.google.com is used, the error of "message": "Invalid Value" occurs. But, when sample is used as the calendar ID, "message": "Not Found" is returned. It seems that the API might search the calendar. In this case, even when the URL encoding is used, the same issue occurs. From this situation, I thought that this might be a bug.
But, I'm not sure whether this is the current specification or a bug. So, I searched this situation at the issue tracker. But, unfortunately, I couldn't find the same issue. So how about reporting this at the Google issue tracker? Ref
Reference:
Calendars: clear
Something to add to this when I encountered the same issue. Seeing that clearing secondary calendars of events is not currently an option, you can outright delete the calendar and re-create it however, the downside to this is the change in the calendar id on re-creation.
Delete calendar documentation
Deletes a secondary calendar. Use calendars.clear for clearing all events on primary calendars.
I am unable to do the /clear action using Google Calendar API with a secondary calendar. I get the same error using either a javascript implementation or directly from their own API explorer at https://developers.google.com/calendar/v3/reference/calendars/clear
To reproduce this, please try the following:
Create a secondary calendar using the calendar subdomain (or whatever method you prefer)
Note the ID of the calendar (looks like xxxxxxxxxxxxxxxxxxxxxxxx#group.calendar.google.com)
Go to their API Explorer for the call: https://developers.google.com/calendar/v3/reference/calendars/clear
Enter your calendar id in the field on the right labeled "calenderId".
Enable "OAuth 2", Disable "API Key".
Tap the EXECUTE button at the bottom.
I get the error 400 "Invalid Value". I've tried this on multiple unrelated accounts with the same result. This seems to be a serious flaw. Has anyone had success with the /clear endpoint for secondary calendars as specified by the calendarId?
Right at the top it clearly says "Primary Calendar", but then it seems a little nuts to also need to provide a calendar ID. sigh
I've been attempting to log activity on a mobile-like device using the Google Analytics Measurement Protocol. All of these attempts have validated using the validation URL, and I can see activity when I look at the real-time reports on the Analytics website. But when I look at the Home or Overview reports for the day - no activity is shown.
The view is set for "All Mobile App Data".
The POST body looks something like this:
v=1&tid=UA-000000000-1&ds=app&qt=1601&uid=uid-zzzzz&t=screenview&cd=Foo&an=Foo%20App%20Name&aid=com.example.foo&aiid=com.example.foo&av=0.0.1&ua=Mozilla%2F5.0%20(Linux%3B%20Android%207.0%3B%20SM-G930V%20Build%2FNRD90M)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F59.0.3071.125%20Mobile%20Safari%2F537.36
The ua field is just a pre-defined string. I found that if I omitted it, the Real Time monitoring listed the hits as desktop hits, although I was in a Mobile report and the ds field was "app".
Am I missing a field that is required? Is there some reason why it is showing up in the real-time report, but not in a daily report? Is there some other way to diagnose why the data is vanishing, or confirm the data is actually being captured?
When i check the debug endpoint the hit is valid
Request:
https://www.google-analytics.com/debug/collect?v=1&tid=UA-XXX-1&ds=app&qt=1601&uid=uid-zzzzz&t=screenview&cd=Foo&an=Foo%20App%20Name&aid=com.example.foo&aiid=com.example.foo&av=0.0.1&ua=Mozilla%2F5.0%20(Linux%3B%20Android%207.0%3B%20SM-G930V%20Build%2FNRD90M)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F59.0.3071.125%20Mobile%20Safari%2F537.36
Response
{
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ ],
"hit": "/debug/collect?v=1\u0026tid=UA-53766825-1\u0026ds=app\u0026qt=1601\u0026uid=uid-zzzzz\u0026t=screenview\u0026cd=Foo\u0026an=Foo%20App%20Name\u0026aid=com.example.foo\u0026aiid=com.example.foo\u0026av=0.0.1\u0026ua=Mozilla%2F5.0%20(Linux%3B%20Android%207.0%3B%20SM-G930V%20Build%2FNRD90M)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F59.0.3071.125%20Mobile%20Safari%2F537.36"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
}
I cannot use one of the mobile libraries from Firebase - this is not one of the platforms they support. I do not wish to pretend this is a web page - there is no associated hostname or path. I do not wish to use Events since I can't do event Behavior Flow, which is one of the things I'm interested in seeing.
I'm aware that it can sometimes take "a day or so" for results to first appear. The site was setup over five days ago at this point, and has received data during that time.
Good thought about the anti-spam setting, however the setting appears to be correct:
I've also tried using GET instead of POST - no change, it still shows the hit in real-time, but then it vanishes.
However, I know that it can record hits permanently. There were two hits from a spammer in Russia that have shown up in the daily report (I wasn't there to see it show up in real-time). I don't know what they did, but would love to find out since it might help figure out how I can add a record.
In the real-time reports, it correctly points out the data center all the hits are coming from. Perhaps that is filtering it out somewhere out of my control?
Try adding Cid I know it says this is an optional parameter but for mobile accounts I belive it may be required.
Client ID
Optional.
This field is required if User ID (uid) is not specified in the request. This anonymously identifies a particular user, device, or browser instance. For the web, this is generally stored as a first-party cookie with a two-year expiration. For mobile apps, this is randomly generated for each particular instance of an application install. The value of this field should be a random UUID (version 4) as described in http://www.ietf.org/rfc/rfc4122.txt.
Example value: 35009a79-1a05-49d7-b876-2b884d0f825b
Although this says it needs to be a UUIDv4, it does work with other UUIDs (I've tested it with a v5, which is a hash against the value used for the uid parameter).
The Google Calendar specifies that it will return an array of Event resources that will also include:
attendees[].id (string) The attendee's Profile ID, if available. It
corresponds to theid field in the People collection of the Google+ API
However, when I invoke the Events:list API it returns me an attendee with the following properties only:
{
"email": "attendee.address#gmail.com",
"displayName": "Attendee Name",
"responseStatus": "accepted"
}
I would like to fetch more information (and namely the user avatar) for this user/attendee by invoking the Google+ API, however, without an ID I can't do much.
The endpoint that I am using to fetch events is https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events?${params} which I confirm is the latest API version.
Any thoughts on this issue would be much welcome!