Data not exposed as JSON when using 'WCF Restful service'

4 posts, 0 answers
  1. Ramakrishna
    Ramakrishna avatar
    4 posts
    Member since:
    Sep 2012

    Posted 18 Oct 2012 Link to this post

    I trying to get work on WCF Restful service on a template 'WCF Service library'

    implemented Domain model and Domain model service with the use of Telerik OA.
    And configured endpoints for the service as well.

    Now the tricky issue comes where the generated methods a. ReadAccountsByXML() and ReadAccountsByJson() both exposes only XML data why?

    //Ramakrishna
  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 22 Oct 2012 Link to this post

    Hello Ramakrishna,

    Could you please give us more details on how you created the service? Did you use the Add OpenAccess Service wizard or you created it manually?

    Please note that you have to specify different Uri template for the methods serializing in JSON as well as set the ResponceFormat parameter of the WebGet attribute to Json. Here is how your method should look like:
    [WebGet(UriTemplate = "?format=json", ResponseFormat = WebMessageFormat.Json)]
    [OperationContract]
    ItemInfoList<Account> ReadAccountsByJson();

    Please give this a try and let us know if it does not help.

    Regards,
    Alexander
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
  3. DevCraft banner
  4. Ramakrishna
    Ramakrishna avatar
    4 posts
    Member since:
    Sep 2012

    Posted 25 Oct 2012 Link to this post

    I used 'Add OpenAccess Service wizard' not manual.

    I can see the specified attributes were there by default.

    what might I missing to get work ?


    //Ramakrishna
  5. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 29 Oct 2012 Link to this post

    Hello Ramakrishna,

    When you call the service, do you add the "?format=json" parameter to the Uri?
    If possible, please give us more details about your method definition and the way you are calling it, so we could try to reproduce this behavior on our side.

    Greetings,
    Alexander
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Back to Top