How can I get an image from Podio using the Podio .NET API?

Answered

Comments

3 comments

  • Andreas Haugstrup Pedersen

    Hi Ken,

    As far as I can see you are attempting to get a file object by using the ItemService. That will of course not work. Unfortunately, the FileService that you'll need to use is quite barebones. It only has an UploadFile method at the moment. So you'll need to either use the PodioRestHelper directly or add the missing methods to FileService yourself.

    Inside your loop the "image" variable already holds a file object. Instead of using the FileId you'll need to access the "link" property which holds a URL from where the file can be downloaded. Simply fetch the contents of this URL (while remembering the send along the regular oauth authorization header that's included in all API requests).

    Then you can do with the file as you wish. For example storing it on a local disk, uploading it to a different server or whatever you want to do.

    All the best,

    Andreas

     

    0
    Comment actions Permalink
  • Ken Lee

    I am still not able to get it to work           

     string requestUri = "https://citrix.podio.com" + "/oauth/token";      

     Dictionary<string, string> _requestbody = new Dictionary<string, string>() {

                    {"grant_type","app"} ,

                    {"client_id",podioClientId},

                    {"client_secret",podioClientSecret},

                    {"app_id",podioAppID.ToString()},

                    {"app_token",podioToken},

                    {"redirect_uri",requestUri} };

    var _response = Podio.API.Utils.PodioRestHelper.Request<Podio.API.Client.AuthorizationAccessToken>(requestUri, _requestbody, Podio.API.Utils.PodioRestHelper.RequestMethod.POST).Data;

                _response.TimeObtained =DateTime.Now;

     //####Response with access token appears to be good at this point

     var f = Podio.API.Utils.PodioRestHelper.Request<Podio.API.Utils.PodioCollection<Item>>("https://citrix.podio.com" + "/ix/files/40025013" + "//", _response.AccessToken);

    // ## it want me to log in the f._response.Data = {"status":"redirect","data":{"url":" https://podio.com/login"}}    

    //## if I enter the request uri " https://citrix.podio.com/ix/files/40025013"   ((minus the "//?oauth_token=x") in to my browser it displays.

    var g = Podio.API.Utils.PodioRestHelper.Request<Podio.API.Utils.PodioCollection<Item>>("https://files.podio.com" + "/40025013" + "//", _response.AccessToken);

    //## g.Response.Data="Not Found"

    //## g.Response.RequestUri= https://files.podio.com/40025013//?oauth_token=xxxxxxxxxxxxxxxxxxx" (token replaced with x's. If I enter this uri " https://files.podio.com/40025013" into my browser it shows the file

    Any suggestions on what I am doing wrong?

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Hi Ken,

    You have a trailing slash in the file download URL. Our file URLs do not have trailing slashes.

    This is why I recommended that you use the "link" property of the file object you already have available. It's guaranteed to always be the correct URL for the file.

    All the best,

    Andreas

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk