1

I am currently trying to wrap an internal API and make it external. To do so, I am trying to relay the JSON responses from the internal API and send that exact response when someone makes a get request. Instead, ASP .NET is JSONifying that son and adding extra back slashes as escape characters (when in fact those slashes are really escape slashes put in by the internal api).

How can i get it so asp does not jsonify the string

1 Answer 1

1

You can write your json data directly to response and set right content headers.

public HttpResponseMessage GetData()
{
    var json = "\"value\": \"da\\ta\"";
    var resp = Request.CreateResponse(HttpStatusCode.OK);
    resp.Content = new StringContent(json);
    resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
    resp.Content.Headers.ContentEncoding = //your json encoding, you can get it from response inner API

    return resp;
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.