Call WCF service method

Posted by Community Admin on 03-Aug-2018 13:56

Call WCF service method

All Replies

Posted by Community Admin on 13-Apr-2011 00:00

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!

Posted by Community Admin on 13-Apr-2011 00:00

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


Posted by Community Admin on 13-Apr-2011 00:00

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.

Posted by Community Admin on 14-Apr-2011 00:00

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


This thread is closed