Level up your Box knowledge with brand new learning paths on Box University. Visit training.box.com to get started

Expiration dates for Shared Link through API

New post

Comments

1 comment

  • kendomen

     

    string url = "https://api.box.com/2.0/files/" + file_id + "/";
    
    HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url);
    webrequest.Method = "PUT";
    webrequest.ContentType = "application/json";
    webrequest.Headers.Add("Authorization", "Bearer " + TOKEN);
    webrequest.Headers.Add("As-User", user_id);
    
    using (var streamWriter = new StreamWriter(webrequest.GetRequestStream()))
    {
          string json = "{\"shared_link\": " +
                        "{\"unshared_at\": null}}";  // sets expiration to none
          streamWriter.Write(json);
          streamWriter.Flush();
          streamWriter.Close();
    }
    
    try
    {
          var response = (HttpWebResponse)webrequest.GetResponse();
          using (var streamReader = new StreamReader(response.GetResponseStream()))
          {
               var result = streamReader.ReadToEnd();
               Console.WriteLine("Success: " + url);
          }
    }
    catch (Exception e)
    {
          Console.WriteLine(e.Message);
    }
    }

     

    0
    Comment actions Permalink

Post is closed for comments.