Copied to clipboard

Flag this post as spam?

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


  • Ronen Rimon 22 posts 124 karma points
    Oct 17, 2017 @ 15:29
    Ronen Rimon
    0

    content update with UmbracoApiController

    I currently building api to update and retrieve content. everything is working great.

    the issue is that after I'm updating a content document I can see the updated values in the back office

    but when I retrieve the content problematically I get the old values for about 15 minutes then it is updated (or after I rebuild the project)

    it looks like it is something to do with cache, but I can't work it out I tried to use

    library.UpdateDocumentCache(content.Id);

    or

    library.RefreshContent();

    after I updated the values but it is not working

    ** I just discovered something very strange, when I use

    Guid contentId ApplicationContext.Current.Services.ContentService.GetById(contentId)

    I get the old values of the content

    and when I use

    int contentId ApplicationContext.Current.Services.ContentService.GetById(contentId)

    I get the updated values

    I really don't understand :(

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Oct 18, 2017 @ 21:14
    Alex Skrypnyk
    0

    Hi Ronen

    How did you save the documents?

    Can you show all your code?

    Thanks,

    Alex

  • Marcio Goularte 388 posts 1360 karma points
    Oct 19, 2017 @ 01:24
    Marcio Goularte
    0
    <XmlContentCheckForDiskChanges>False</XmlContentCheckForDiskChanges>
    

    Change in umbracoSettings.config to true

    https://our.umbraco.org/documentation/reference/config/umbracosettings/

  • Ronen Rimon 22 posts 124 karma points
    Oct 20, 2017 @ 07:27
    Ronen Rimon
    0

    thanks for you reply but it didn't do the job,

    I even tried to disable the cache

    and it didn't changed the situation

    the only thing that helped is that I replaced the call from

    var content = ApplicationContext.Current.Services.ContentService.GetById(contentKey); //contentKey is the guid documet key

    to

    int contentId = ApplicationContext.Current.Services.EntityService.GetIdForKey(contentKey, (UmbracoObjectTypes)Enum.Parse(typeof(UmbracoObjectTypes), "Document", true)).Result;

    var content = ApplicationContext.Current.Services.ContentService.GetById(contentId); //contentId is the integer documet id

Please Sign in or register to post replies

Write your reply to:

Draft