Skip to content

Instantly share code, notes, and snippets.

@peted70
Created June 17, 2016 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peted70/b3ed42aa14ea9324ed05b22d5b2c693b to your computer and use it in GitHub Desktop.
Save peted70/b3ed42aa14ea9324ed05b22d5b2c693b to your computer and use it in GitHub Desktop.
private async Task<string> GetActivity(string token, string activity, DateTime Start, DateTime end)
{
string res = string.Empty;
try
{
res = await MakeRequestAsync(token, "me/Activities/",
string.Format("startTime={0}&endTime={1}&activityTypes={2}&ActivityIncludes=Details",
Start.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"),
end.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"),
activity));
}
catch (Exception ex)
{
return $"API Request Error - {ex.Message}";
}
await Task.Run(() =>
{
// Format the JSON string
var obj = JsonConvert.DeserializeObject(res);
res = JsonConvert.SerializeObject(obj, Formatting.Indented);
});
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment