1
votes

I am making an app for my school. The school uses a Google Calendar to schedule all of their events. They would like me to implement the events from their calendar into the app.

I am using the Google Calander API. Since I will only be pulling information from one account there is no need for user authentication.

I have my API key and made sure my events on my google calendar are visible to everybody.

This is the JSON result that I am presented with upon running.

enter image description here

Here is the code in my HomeController

    override func viewDidLoad() {
    super.viewDidLoad()


    //Event call from Google API

    let url = NSURL(string: "https://www.googleapis.com/calendar/v3/calendars/<THE EMAIL ACCOUNT>/events?maxResults=15&key=APIKey-<MY API KEY>")
    let task = URLSession.shared.dataTask(with: url! as URL) {(data, response, error) in
        let dataAsNSString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
        print(dataAsNSString)
    }
    task.resume()

}
1

1 Answers

1
votes

Your error is due to the either the fields query parameter has an error or is otherwise invalid. If you check the documentation, that was introduced there.

Suggested action: Because this is a permanent error, do not retry. Read the error message instead and change your request accordingly.