NewsItemService.svc response is incorrect?

Posted by Community Admin on 04-Aug-2018 16:51

NewsItemService.svc response is incorrect?

All Replies

Posted by Community Admin on 25-Jan-2012 00:00

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

Posted by Community Admin on 30-Jan-2012 00:00

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

Posted by Community Admin on 30-Jan-2012 00:00

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?

Posted by Community Admin on 30-Jan-2012 00:00

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

Posted by Community Admin on 17-Feb-2015 00:00

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

[quote]Svetoslav Petsov said:it is used when working with/changing the current item. The Persisted Value is what gets written in the database. [/quote]
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?

[quote]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).[/quote]

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.

This thread is closed