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

Forums / General Discussions / Call WCF service method

Call WCF service method

4 posts, 0 answered
  1. Eugene Gvozdarev
    Eugene Gvozdarev avatar
    10 posts
    Registered:
    06 Jan 2010
    13 Apr 2011
    Link to this post
    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!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Apr 2011
    Link to this post
    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

  3. Eugene Gvozdarev
    Eugene Gvozdarev avatar
    10 posts
    Registered:
    06 Jan 2010
    13 Apr 2011
    Link to this post
    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.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    14 Apr 2011
    Link to this post
    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

4 posts, 0 answered