I am a complete beginner to both iOS dev and working with Google's APIs. I'm learning both of them simultaneously so I apologize if this is a newbie question.
The Parsing Error has been "repealed & replaced" with a new API error below
I am trying to write an app that will tell me, that at the time of API request, whether the calendar is in the middle of an event or not.
I tried using this answer posted on a similar question.
My code looks like this now: (LOOK AT BOTTOM FOR UPDATES)
let json = "{ \"timeMin\": \(currentDate), \"timeMax\": \(currentDate)}"
urlString = "https://www.googleapis.com/calendar/v3/freeBusy"
let url = URL(string: urlString)!
let jsonData = json.data(using: .utf8, allowLossyConversion: false)!
var request = URLRequest(url: url)
request.httpMethod = HTTPMethod.post.rawValue
request.setValue("application/json; charset=UTF-8", forHTTPHeaderField: "Content-Type")
request.httpBody = jsonData
Alamofire.request(request).responseJSON {
(response) in
print (response)
}
And i get the following output: (Note: This is fixed by specifying in the json parameter which calendar to retrieve info from)
SUCCESS: {
error = {
code = 400;
errors = (
{
domain = global;
message = "Parse Error";
reason = parseError;
}
);
message = "Parse Error";
};
}
I am unsure how to proceed from here- also, is making a freebusy POST request even the best way to go about solving my problem?
UPDATE:
So I recognized that in my body parameter, I was not specifying which calendar to request information from: I made the following adjustments:
var body : Parameters = [
"timeMin": dateString,
"timeMax": dateString,
"items": [
[
"id": CALENDAR_ID
]]
]
Alamofire.request(url, method: HTTPMethod.post, parameters: body, encoding: JSONEncoding.default).responseJSON {
(response) in
print(response)
}
}
However, now I get the following error:
SUCCESS: {
error = {
code = 403;
errors = (
{
domain = usageLimits;
extendedHelp = "https://code.google.com/apis/console";
message = "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.";
reason = dailyLimitExceededUnreg;
}
);
message = "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.";
};
}