Call WCF service method
Hi
I'm trying to use REST WCF services. I need to get news item by news id. I use the next url:
/Sitefinity/Services/Content/NewsItemService.svc/Id
where id is Guid, i.e. news id.
But if I logined on website as administrator I have the next response:
"Detail":"The item is in an invalid state. It should be master (draft)."
If I'm anonymous I have the next response:
"Detail":"..::login|session|expired::..\/Sitefinity\/Login\/Ajax"
Also I have added permission for all roles for View news action
And all news are published.
Could you please help me?
How can I use NewsItemService.svc for anonymous? (It would be great to have easy example)
Thanks a lot!
Hello Eugene ,
You cannot call the service if the user is not authenticated. We check for the current user and whether this is authenticated by using ServiceUtility.RequestAuthentication();. So there should be a valid user in the context.
Greetings,
Ivan Dimitrov
the Telerik team
Thanks for the reply, Ivan!
I tried do the next:
1. Login as admin
2. Call /Sitefinity/Services/Content/NewsItemService.svc/Id method
But response is
"Detail":"The item is in an invalid state. It should be master (draft)."
Why? All news have 'Published' status.
Thanks.
Hi Eugene,
You are passing an invalid ID. You should use the master version of the item
var newsManager = NewsManager.GetManager();
var items = newsManager.GetNewsItems().Where(item => item.Status == GenericContent.Model.ContentLifecycleStatus.Master);
Regards,
Ivan Dimitrov
the Telerik team