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

Newlines in description #81

Open
mrjcleaver opened this issue Oct 2, 2015 · 4 comments
Open

Newlines in description #81

mrjcleaver opened this issue Oct 2, 2015 · 4 comments

Comments

@mrjcleaver
Copy link

I was trying to put newlines in the description. Failed with a parse error.

Per http://stackoverflow.com/questions/7830582/newline-for-google-calendar-api it turns out this needs to be json escaped. Tried using solution on http://stackoverflow.com/questions/6783988/encode-a-ruby-string-to-a-json-string only to find that something objected to the leading and trailing quote.

      description_json = description.to_json
      description_json.gsub!(/\A"|"\Z/, '')

      event = @cal.create_event do |e|
        e.title = title
        e.start_time = time_object_start
        e.end_time = time_object_end
        e.description = description_json
      end

Is my ugly workaround.

@mrjcleaver mrjcleaver mentioned this issue Oct 2, 2015
@szich
Copy link
Member

szich commented Oct 3, 2015

@mrjcleaver feel like improving the parse method so it properly escapes the strings?

@PandaWhisperer
Copy link

+1. Just ran into the same issue. Came here to find that there's already an issue for it.

PS: thanks for the workaround @mrjcleaver, you saved me a bunch of time.

@ziazek
Copy link

ziazek commented Oct 21, 2015

Using @mrjcleaver's workaround allows me to save a new event to Google Calendar, but the subsequent

cal.find_or_create_event_by_id('db8viph0q6cidplta2f2ji3lm4')

results in

Google::HTTPRequestFailed:
{
  "error": {
    "errors": [
    {
      "domain": "global",
      "reason": "parseError",
      "message": "Parse Error"
    }
    ],
    "code": 400,
    "message": "Parse Error"
  }
}

@ziazek
Copy link

ziazek commented Oct 21, 2015

Update: If I pass a block to find_or_create_event_by_id to update that same event, there is no error. The error only shows up when there's no block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants