Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Richard Han 19 posts 41 karma points
    Aug 15, 2013 @ 11:59
    Richard Han
    0

    Get JSON output by UmbracoApiController

    As title , is any way can do it ? 

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Aug 15, 2013 @ 12:30
    Dave Woestenborghs
    1

    Yep..You can find the docs here : http://our.umbraco.org/documentation/Reference/WebApi/

  • Richard Han 19 posts 41 karma points
    Aug 15, 2013 @ 12:49
    Richard Han
    0

    Thanks dawoe,  But my question is the output have unnecessary element.  I want to pure string.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Aug 15, 2013 @ 13:14
    Dave Woestenborghs
    0

    What do you mean with unnecessary element ?

  • Richard Han 19 posts 41 karma points
    Aug 15, 2013 @ 14:48
    Richard Han
    0

    I figure out now.. no unnecessary element.

    The browser behavior seems a little bit difference.

    Chrome:

    <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">{"boolean": true,"string": "Hello World"}</string>


    Firefox : 

    <string>{"boolean": true,"string": "Hello World"}</string>

     

    IE & jQuery method get result is good.

    {"boolean": true,"string": "Hello World"}

     

    Very thanks.


  • Stefan Kip 1614 posts 4131 karma points c-trib
    Aug 16, 2013 @ 09:13
  • Tom 713 posts 954 karma points
    Sep 16, 2013 @ 01:52
    Tom
    0

    I implemented the removal of the xml formatter but am still getting xml back..

    any suggestions?

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Sep 16, 2013 @ 08:44
    Stefan Kip
    0

    Try to add the right Content-Type request-header with a value of "application/json".

  • Richard Han 19 posts 41 karma points
    Nov 07, 2013 @ 08:26
    Richard Han
    1

    the easy way.

            [HttpGet]

            public HttpResponseMessage GetJson()

            {

                HttpContext.Current.Response.ContentType = "application/json";

                HttpContext.Current.Response.Write("{\"status\":\"OK\"}");

                return new HttpResponseMessage();

            }

  • Halima Koundi 8 posts 79 karma points
    Feb 12, 2016 @ 16:59
    Halima Koundi
    0

    This code worked for me Exactly what I need to output pure json data back from the WebApi controller

    cheers

  • Jeric 122 posts 192 karma points
    Dec 18, 2013 @ 17:28
    Jeric
    0

    Hey gwweee,

    I'm trying to do the same thing with but to render a list of children under a specific node which will show only a single property value in the JSON.

    Can't seems to figure out how this is done with the UmbracoApiController. Any help will be much appreciated

  • Richard Han 19 posts 41 karma points
    Nov 16, 2016 @ 11:22
    Richard Han
    0

    what's your code?

Please Sign in or register to post replies

Write your reply to:

Draft