+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / NewsItemService.svc response is incorrect?

NewsItemService.svc response is incorrect?

5 posts, 0 answered
  1. Tim Haynes
    Tim Haynes avatar
    8 posts
    Registered:
    12 May 2010
    25 Jan 2012
    Link to this post
    Has anybody else noticed this, or am I just misunderstanding things?
    The Sitefinity/Services/Content/NewsItemService.svc/help/GetContent/response/example JSON has the following details in the response:

            "Title": {
                "PersistedValue": "String content",
                "Value": "String content"
            },

    However, when I actually call a NewsItemService.svc, I get this in the response, instead:

                "Title": "news test",

    Notice that it doesn't have a PersistedValue child or Value child.  It just lists the Title value itself.

    When I create my own web service within the Sitefinity web app, and return a  CollectionContext<NewsItem>, it returns the first format style:

            "Title": {
                "PersistedValue": "news test",
                "Value": "news test"
            },

    So, what is up with NewsItemService.svc?  Why doesn't it return data in the same form as the example?  Am I missing something?

    Thanks
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    30 Jan 2012
    Link to this post
    Hi,

     This happens because the Title property is of type LString, which is serialized as an object. The Value property is the one that you should use - it is used when working with/changing the current item. The Persisted Value is what gets written in the database. 
    The service returns only the value of the LString, as it properly hides the URI template and returns only the needed property (the persistedValue shouldn't be returned, as it is used only internally in Sitefinity and shouldn't be publicly accessible).

    Regards,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Tim Haynes
    Tim Haynes avatar
    8 posts
    Registered:
    12 May 2010
    30 Jan 2012
    Link to this post
    Thank you for your answer.  However, this implies that the JSON returned by the official example is wrong, since the actual webservice returns different JSON.  Perhaps the official example should be fixed?
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    30 Jan 2012
    Link to this post
    Hello,

     Yes, the URI template in the help page of the service needs to be fixed. Thank you for focusing our attention to it. I updated your Telerik points.

    All the best,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. xr280xr
    xr280xr avatar
    2 posts
    Registered:
    21 Aug 2013
    17 Feb 2015 in reply to Svetoslav Petsov
    Link to this post

    I know this is an old post, but it if you're still around Svetoslav, would you mind clarifying a couple things?

    Svetoslav Petsov said:it is used when working with/changing the current item. The Persisted Value is what gets written in the database.

    I'm trying to understand Lstrings. it looks like they can be tricky to work with. Can you expand on your statement? If I'm changing the current item, don't I want the value I'm setting written in the database? Why then is Value the correct property to use if PerisistedValue gets written in the database?

    Svetoslav Petsov said:The service returns only the value of the LString, as it properly hides the URI template and returns only the needed property (the persistedValue shouldn't be returned, as it is used only internally in Sitefinity and shouldn't be publicly accessible).

    This would be great. So now in version 7.2, why does the NewsItemService GetContent method return the Lstring objects with value and persisted value? Having to deserialize what is logically a single string property to an object with redundant values is difficult to work with.

5 posts, 0 answered