Welcome to the new Box Support website. Check out all the details here on what’s changed.

Can't fetch file's created_On and created_By property, while calling Get Folder’s Items

New post

Comments

1 comment

  • kendomen

    It would be another api call.  This example is takes an ID from the above call and gets the folder or file info.

    public static JObject getFileInfo(string type, string id, string user_id)
    {
           string url = "https://api.box.com/2.0/files/" + id;
    
           if (type == "folder")
               url = "https://api.box.com/2.0/folders/" + id;
    
    
           HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url);
           webrequest.Method = "GET";
           webrequest.ContentType = "application/json";
           webrequest.Headers.Add("Authorization", "Bearer " + TOKEN);
           webrequest.Headers.Add("As-User", user_id);
    
           try
           {
               HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();
               Encoding enc = System.Text.Encoding.GetEncoding("utf-8");
               StreamReader responseStream = new StreamReader(webresponse.GetResponseStream());
               string result = string.Empty;
               result = responseStream.ReadToEnd();
               JObject jResponse = JObject.Parse(result);
               return jResponse;
           }
           catch (Exception e)
           {
               Console.WriteLine(e);
               if (e.Message.Contains("403"))
               {
                   Console.WriteLine("*************** 403 user_id: " + user_id);
               }
               return null;
           }
    }
    0
    Comment actions Permalink

Please sign in to leave a comment.