Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. string uri = string.Format("https://api.box.com/2.0/files/{0}", fileId);
  2. string body = "{"shared_link": {"access": "open"}}";
  3.  
  4. byte[] postArray = Encoding.ASCII.GetBytes(body);
  5.  
  6. using (var client = new WebClient())
  7. {
  8. client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
  9. client.Headers.Add("Authorization: Bearer " + token);
  10.  
  11. var response = client.UploadData(uri, postArray);
  12.  
  13. var responseString = Encoding.Default.GetString(response);
  14. }
  15.  
  16. string uri = String.Format(UriFiles, fileId);
  17. string response = string.Empty;
  18. string body = "{"shared_link": {"access": "open"}}";
  19. byte[] postArray = Encoding.ASCII.GetBytes(body);
  20.  
  21. try
  22. {
  23. using (var client = new WebClient())
  24. {
  25. client.Headers.Add("Authorization: Bearer " + token);
  26. client.Headers.Add("Content-Type", "application/json");
  27. response = client.UploadString(uri, "PUT", body);
  28. }
  29. }
  30. catch (Exception ex)
  31. {
  32. return null;
  33. }
  34. return response;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement