Skip to content

Instantly share code, notes, and snippets.

@jskopek
Created April 24, 2018 07:11
Show Gist options
  • Save jskopek/db2aeac10475f9e4aeb394fcfc193f4d to your computer and use it in GitHub Desktop.
Save jskopek/db2aeac10475f9e4aeb394fcfc193f4d to your computer and use it in GitHub Desktop.
public async Task<string> GenerateAccessPolicy(string name, int durationInMinutes, int permissions)
{
// create access policy
var accessPolicyBody = new
{
Name = name,
DurationInMinutes = durationInMinutes,
Permissions = permissions
};
var bodyContent = JsonConvert.SerializeObject(accessPolicyBody);
HttpResponseMessage accessPolicyResponse = await _httpClient.PostAsync("AccessPolicies", new StringContent(bodyContent, Encoding.UTF8, "application/json"));
string responseContent = await accessPolicyResponse.Content.ReadAsStringAsync();
var obj = JObject.Parse(responseContent);
return obj["d"]["Id"].ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment