Why won't Google Calendar load my dynamically generated ICS file? - asp.net

I've been given the task of creating an ICAL feed of conference calls for members of our organization. I created a handler in ASP.NET that loops through our database, gets the call data from the database, and creates output that appears valid to me based on what I've read of the ICAL format, and the examples I've seen/disassembled.
Outlook 2007 reads the resulting output and displays the calendar, no problem (screenshot here shows how it renders).
30 Boxes also has no problem with it. (see test here).
But when I try to load the same output into Google Calendar, I get the message "We could not parse the calendar at the url requested":
What's wrong with my output that's causing Google to reject it? You can see the temporary data I'm testing with at this URL: http://www.joshuacarmody.com/temp/icaltest.ics. This is a snapshot of the output from my .ASHX file, unaltered except the phone numbers and passcodes have been sanitized.
Edit with additional Info:
I just tried the following
Created a copy of my test file called "icaltest-1googevent.ics"
Deleted all the VEVENT data from the file
Exported one of my Google calendars to ICS
Copied one VEVENT from Google's exported data into my test file
Attempted to subcribe to icaltest-1googevent.ics in Google Calendar.
I still got an error message. So I'm guessing the issue isn't with my VEVENT data, but with something else about the file. Maybe there's something wrong with my VCALENDAR definition?

the severinghaus ics validator seems to think there is something funny ( a ? ) before the BEGIN CALENDAR
http://severinghaus.org/projects/icv/?url=http%3A%2F%2Fwww.joshuacarmody.com%2Ftemp%2Ficaltest.ics
In my testing google was a lot fussier/rigourous/pedantic - once you get it working with the validator and google it should work in most places.

After lots of trial-and-error, and comparing my output with Google's, I got it working. There were a few problems with my ICS file:
Unescaped characters (I didn't know I had to escape commas!)
Inconsistent line return characters. They didn't show up in my text editor, but I had to use .NET's String.remove() to remove "\r" from my output to get Google to recognize it
The file was missing VCALENDAR:END. Apparently Outlook doesn't much care. Google does.

I had not one, but three funny characters before the BEGIN:VCALENDAR, decimal codes 239, 187, 191.
I found them thanks to the severinghaus.org link above, thanks!
It turns out they're a prefix called BOM in UTF-8, you can read up on it here: http://en.wikipedia.org/wiki/UTF-8#Byte_order_mark
Google doesn't handle this, but after stripping these three characters from the file and uploading to the server, I was able to susbribe to that calendar in Google Calendar (from URL).
I hope this helps someone passing by this page in the future...

I had similar problem until I realised that opening the generated .ics file in Notepad++ wasn't in UTF-8. I was using a method to convert my string to a byte array, but wasn't using an encoder for this, so no matter what content headers I used, the file would never be generated using UTF-8. This simple fix resolved the UTF-8 generation and Google is now happy with my feed:
var utf8 = Encoding.UTF8;
byte[] utfBytes = utf8.GetBytes(myString);
myString= utf8.GetString(utfBytes, 0, utfBytes.Length);

Related

Postman Collection- Setting Authorization header through code

Everytime I am testing postman collection ,I need to change the authorization token under header manually followed by exporting the collection again and running through newman.
Is there any way , instead of giving here, I can give it in a CSV file which is being used as test data file. which would reduce the efforts of changing code every time.
Please suggest.
Yes you can, in your csv file, add one more column - name as "AT"
and mention that reference AT in your request as in the following picture.

TinyButStrong magnet tag shows in output docx

Hi my colleague and I has been trying to get the TinyButStrong plugin openTBS to create some docx files.
We have a live system which creates some RTF files, with data from MySQL. We want to change this to docx, use openTBS. A couple of super users then in Word manage the templates.
We have a problem with creating the files, as we need to remove a line, if data isn't present.
If we in the Word template do
<w:p>[*fieldname*;magnet=w:p]*some kind of text*</w:p>
it hiddes the line if fieldname contains no data, and if if contains data, it will show the line. GREAT :-)
The problem is, that it also shows <w:p> and </w:p> when it contains data, and we don't like that.
How do we get it to stop showing these tags?
The TBS parameter ope=minv is done for thus purpose: it performs the magnet behavior but keep the field invisible (minv stands for magnet invisible).
So the solution is:
<w:p>[*fieldname*;magnet=tbs:p;ope=minv]*some kind of text*</w:p>
By the way, magnet=tbs:p is better than magnet=w:p because your template stays compatible when converted to another other format (LibreOffice).

Download an excel file as attachment using Qt browser

I am working on Qt browser(code taken from Qt Tab Browser Example). This Qt browser successfully downloads an image file, but not an excel/pdf file. I need to download an excel/pdf file as attachment on click of a button. Excel generation code at back-end uses PHPExcel to generate and finally saves it using 'php://output'.
On browser side, when I read through QNetworkReply's 'readAll()' function, some encoded string '��ࡱ�' gets printed and nothing gets saved in QFile object, totally empty file.
How do I get the desired excel file from this encoded string ?
Please, any help. It is Linux OS and I use LibreOffice if it matters.
Well, got the answer. I was printing QNetworkReply object's content on the console using reply->readAll() before reading it into the file and Qt documentation states that:
QNetworkReply is a sequential-access QIODevice, which means that once
data is read from the object, it no longer kept by the device.
Therefore, i ended up with an empty file. Found this when i printed the size of the 'reply' object. Also, found some eventLoop related help from here(Roozbeh's answer).
Hope it helps someone else as well. Thanks SO !

Collation urls not followed for Google Webmaster

I got lots of not followed page on Google Webmaster. I check them and is because lots of url are like http://www.mysite.net/2013/06/burn-notice-7%C3%9702-sub-espanol-online.html
whe the correct url have to be http://www.mysite.net/2013/06/burn-notice-7x02-sub-espanol-online.html
Im try to post a title wit many "x" on it and the only that weird %C3%97 when I post for example a new serie episode like this title: Burn Notice 7x02 Sub Español Online. When the x is between number appear %C3%97 and that made my posts duplicate.
So I try to fix changed the database collation from latin1_swedish_ci to utf8_general_ci but is still the same happend. I check as well my wp-config.php and is define('DB_CHARSET', 'utf8');
Please, some body know any good solution to fix all this situation? The database is quite big and supouse if I find a solution I need update the old url.
Thank you on advance
The URL you say Google is using:
http://www.mysite.net/2013/06/burn-notice-7%C3%9702-sub-espanol-online.html
is almost the same as the URL:
http://www.mysite.net/2013/06/burn-notice-7x02-sub-espanol-online.html
as the percent encoded characters actually repreesent Unicode Character 'MULTIPLICATION SIGN' aka it's an '×' not an 'x'. Google is just using the percent encoded version to be safe. That means that your database is probably fine, as it is showing URLs as valid UTF8.
The problem probably lies in how you're interpreting the requested URL and trying to match it to the database. PHP should already be decoding the percent encoded value to '×', so either:
Something is breaking the string (e.g. calling a non-multibyte safe function like strtolower() instead of mb_strtolower()).
Your PHP code is connecting to the database in a character set other than UTF8, please check that your my.cnf file contains 'default-character-set=utf8' in the client section.
or there's some other issue. The URL does appear valid though.

Scraping ASP pages with Excel/VBA

I'm trying to scrape an ASP.NET page with Excel. Unfortunately, the page only returns 50 records at a time, of several pages. Excel's native Web Query module only picks up the first page. I want all the pages.
Like most (all?) ASP pages, there are a few hidden variables sent back to the server when requesting a new page. The important ones are _VIEWSTATE and _EVENT_VALIDATION.
I've written a VBA function that gets the HTML source of the page and scrapes these variables from it.
I've also written an .iqy page, which allows for POST requests in it. It looks something like this:
WEB
1
http://www.myaspwebsite/search/search_List.aspx
__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTEy[....truncated ..50k characters..]Mhudyk5U6u8%2BBpvxDPN8R4%3D&__EVENTVALIDATION=%2FwEWFQL%2FkN%2FBCgL6g%2B5vAvfY06EOAoic4qIIAome%2Bf4PAuOrjYgIAuKrjYgIAuGrjYgIAuCrjYgIAuerjYgIAt7e34UPAvuL7m8CtuLToQ4CiaTioggCyKX5%2Fg8C4tv1sAgC49v1sAgC4Nv1sAgC4dv1sAgC5tv1sAgC%2Fd7fhQ%2BU8QRtxd7MM4Bpa%2F%2FZC7I64eUh3Q%3D%3D&ctl00_RadMenu1_ClientState=&ctl00%24ContentPlaceHolder1%24NavBar1%24PageNoDropDownList=2&ctl00%24ContentPlaceHolder1%24NavBar1%24btnGo=Go&ctl00%24ContentPlaceHolder1%24NavBar2%24PageNoDropDownList=1
Selection=AllTables
Formatting=None
PreFormattedTextToColumns=True
ConsecutiveDelimitersAsOne=True
SingleBlockTextImport=False
DisableDateRecognition=False
DisableRedirections=False
This iqy page successfully retuns the desired results if the post query is placed in the file.
I can also use this .iqy page programmatically in VBA and assign the POST query dynamically using QueryTables. However, I get told that my query returned nothing.
I suspect this is because of the length of my argument. The VIEWSTATE alone is about 50k characters. I've tried printing the argument string to a file and it truncates it. However, I can read the same string from a file and use it dynamically successfully.
My questions are : Am I going about this the best way? What limitations should I be aware of when doing this? Also, is there a limit to string size in Excel?
According to Microsoft's documentation on Visual Basic strings (same value applies to VBA strings):
A string can contain from 0 to approximately two billion (2 ^ 31) Unicode characters.
That is more than enough to handle a 50k string. A simple way to bypass IDE line limits and immediate window printing limits would be to print the string into an Excel cell and then read it back into a variable when you need to use that piece of data.

Resources