Forum Discussion

superska's avatar
superska
New Contributor
12 years ago

JSON Formatting issue

Hi,

I must be doing something wrong...

I'm calling my own REST service from within SoapUI. I get an answer from the service, but it shows as an encoded string in stead of nicely formatted JSON:
"{\"Items\":[{\"FavoritesListGuid\":\"75b02f79-ddbc-4124-96a4-5b60b8559503\",\"Name\":\"Wenslijst\",\"Created\":\"2014-03-03T13:28:23.207\",\"CreatedBy\":null,\"Updated\":\"2014-03-03T13:28:23.207\",\"UpdatedBy\":null,\"TotalAmount\":0.0,\"ProductCount\":0,\"CustomerUserId\":-1,\"Products\":null}],\"Count\":1}"

When I call the service in a browsder, or when I look at the response with Fiddler, I don't see those escaping characters.

Any ideas?

Thanks!
Stefan

3 Replies

  • SiKing's avatar
    SiKing
    Community Expert
    Looking at the response headers might give you a clue.
  • superska's avatar
    superska
    New Contributor
    Hi, thanks for your answer.

    Looking at the response headers, I don't really get a clue. But that might very well be caused by my lack of knowledge in that area. These are my response headers:

    [b]X-AspNet-Version[/b] 4.0.30319
    [b]Date[/b] Tue, 04 Mar 2014 09:56:38 GMT
    [b]Content-Length[/b] 329
    [b]#status#[/b] HTTP/1.1 200 OK
    [b]Expires[/b] -1
    [b]Content-Type[/b] application/json; charset=utf-8
    [b]Server[/b] Microsoft-IIS/8.5
    [b]X-Powered-By[/b] ASP.NET
    [b]Cache-Control[/b] no-cache
    [b]Pragma[/b] no-cache


    I'm suspecting the Content-Type might need to different?

    Greetz,
    Stefan
  • GiscardN's avatar
    GiscardN
    Frequent Contributor
    Hi,

    I looks like your service is returning a String. It's possible there is an automatic parsing that the browser makes and you are not seeing it when calling your service from SoapUI. Aside from the "\" characters and the enclosing quotations for the entire String, it's a valid JSON.

    Regards,

    Giscard
    SmartBear Support