private string GetUploadLink(RequestTokenModel model, string path) { var uploadModel = new UploadInfoRequestModel() { description = "file description", mimeType = "text/plain", title = "test file" }; var json = _service.GetUploadModel(model.Token, uploadModel).Result; return(JsonConvert.DeserializeObject <UploadInfoResponseModel>(json).id); }
/// <summary> POST https://www.googleapis.com/drive/v2/files </summary> public async Task <string> GetUploadModel(string token, UploadInfoRequestModel model) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(GoogleDriveAppClient.BaseUrl); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token); var content = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json"); var result = await client.PostAsync("/drive/v2/files", content); return(await result.Content.ReadAsStringAsync()); } }