attempting to fetch images of a private unlisted group wiki page via API

Hi,

We are trying to fetch content and its images of a wiki page from api call of a private unlisted group.  we are able to fetch the content but if we are trying to retrieve images its throwing error 403 error as forbidden.

even we tried with admin login also no luck :( 

Parents
  • We tried the following case:

    case 1 : we had created a plugin , tried 

    Apis.Get<IUsers>().RunAsUser(RunAsUserID, () =>
    				{
    				
    			image = Image.GetInstance(src);
    				});
     

    case 2:

    using Rest sdk

    var         adminKey = String.Format("{0}:{1}", "8nobz9x7io5b4r4d", "abcd");
    			var adminKeyBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(adminKey));
    			string imageurl = "http://devcommunity.name.com/resized-image/__size/320x240/__key/communityserver-wikis-components-files/00-00-00-00-04/google.png";
    			using (var client = new WebClient())
    				{
    					client.Headers.Add("Rest-User-Token", adminKeyBase64);
    					byte[] imageBytes = client.DownloadData(imageurl);
    					var data = imageBytes;
    					var imagearray = Convert.ToBase64String(data);
    					var dataUrl = "data:image/png;base64," + imagearray;
    				}

    For both the cases it throws error as follows:

    NVelocity.Exception.MethodInvocationException: Invocation of method 'imageinstances' in  GetImagesOfWikis threw exception System.Net.WebException : The remote server returned an error: (403) Forbidden. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.
       at System.Net.HttpWebRequest.GetResponse()

    It works fine for all Group Types Except Private Listed & Private Unlisted.

  • Instead of attempting to use the url directly you probably need to break it down and use the Cfs endpoint:  https://community.telligent.com/community/10/w/api-documentation/61480/show-cfs-rest-endpoint

    Filestore: communityserver-wikis-components-files

    path:  00-00-00-00-04

    file: google.png

    If those do not work replace the dashes (-) with periods (.)

  • Hi,

    We tried  above case  but it throws an exception like

    Telligent.Evolution.RestSDK.Exceptions.JsonParseError: 'ReadTo could not find value (") started at (0).'
    
    Telligent.Evolution.RestSDK.Exceptions.JsonBadFormat: 'Json contains invalid format.'

    we tried as follows

    var host = new ClientCredentialsRestHost("username", "http://devcommunity.sample.com/", "oauthid", "oauthsecret");
    			var response = host.GetToDynamic(2, "cfs/{fileStore}/{filepath}/{filename}", false, new RestGetOptions
    			{
    				PathParameters = new System.Collections.Specialized.NameValueCollection {
    	  { "fileStore", "communityserver.wikis.components.files" },
    	  { "filepath", "00-00-00-00-04" },
    	  { "filename", "google.png" }
    				}
    			});
    

Reply
  • Hi,

    We tried  above case  but it throws an exception like

    Telligent.Evolution.RestSDK.Exceptions.JsonParseError: 'ReadTo could not find value (") started at (0).'
    
    Telligent.Evolution.RestSDK.Exceptions.JsonBadFormat: 'Json contains invalid format.'

    we tried as follows

    var host = new ClientCredentialsRestHost("username", "http://devcommunity.sample.com/", "oauthid", "oauthsecret");
    			var response = host.GetToDynamic(2, "cfs/{fileStore}/{filepath}/{filename}", false, new RestGetOptions
    			{
    				PathParameters = new System.Collections.Specialized.NameValueCollection {
    	  { "fileStore", "communityserver.wikis.components.files" },
    	  { "filepath", "00-00-00-00-04" },
    	  { "filename", "google.png" }
    				}
    			});
    

Children