Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Damion 96 posts 331 karma points
    Aug 20, 2019 @ 14:40
    Damion
    0

    Creating media item with IMediaService

    I wonder if anyone can point me in the right direction with this.

    I'm using IMediaService in v8 as specified here to create a media item, but it fails on the line

    var item = _mediaService.CreateMedia(itemName, id, itemTypeAlias, _automatonId);
    

    with the error

    Value cannot be null.\r\nParameter name: parent

    As far as I can tell I've included everything I need to call CreateMedia, any ideas?

    thanks

  • Shaishav Karnani from digitallymedia.com 354 posts 1638 karma points
    Aug 20, 2019 @ 15:45
    Shaishav Karnani from digitallymedia.com
    1

    Yes the function syntax is .CreateMedia(string name, int parentId, string mediaTypeAlias, [int userId = 0])

    and it looks correct from your method but please can you double check that "id" is not null and is parentId in your createmedia statement.

  • Damion 96 posts 331 karma points
    Aug 20, 2019 @ 15:49
    Damion
    0

    Hi,

    thanks for replying, id is definitely populated with the relevant guid and being passed in where parentId should be - not sure what the issue is.

  • Shaishav Karnani from digitallymedia.com 354 posts 1638 karma points
    Aug 20, 2019 @ 16:25
    Shaishav Karnani from digitallymedia.com
    0

    Instead of GUID - please can you pass int parentID and try as method is accepting integer.

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    Aug 20, 2019 @ 22:13
    Paul Seal
    100

    Hi Damion

    // use this to create the media item
    var media = _mediaService.CreateMedia(nodeName, parentFolderId, nodeTypeAlias);
    
    //if you want to specify the key you can like this
    media.Key = new Guid("db22bb69-b0ae-44bb-9019-a3e6498d4c25");
    _mediaService.Save(media);
    

    I hope this helps

    Paul

  • Damion 96 posts 331 karma points
    Aug 21, 2019 @ 08:55
    Damion
    0

    Cheers Paul,

    I misunderstood what id I should have been passing in, once I passed the parent folder id it worked fine.

Please Sign in or register to post replies

Write your reply to:

Draft