NewsItemService.svc response is incorrect?
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
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).
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?
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,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.