Select to view content in your preferred language

force json mime type to application/json in json response

1211
1
10-24-2012 02:29 PM
ericliprandi
Deactivated User
Hi,
I have read several threads on these forums that sort of explained how to set the Content-Type on a REST response for a .NET SOE. However, I am batting .000 in making this work. The most basic example I want to get working is to use the VS2010 project template for a REST SOE. All I want is force Content-Type header to be application/json instead of the "text/plain;charset=utf-8" that it defaults to.
I have tried the following in SampleOperHandler:
            RestResponseProperties props = new RestResponseProperties();
            props.ContentType = "application/json";
            responseProperties = props.ToString();

also tried the following:
            responseProperties = "{\"Content-Type\": \"application/json\"}";


In either case, the Content-Type Header is not updated to my value. What are we missing? According to RFC 4627, the MIME type for JSON text is application/json. Some of our tools and systems are requiring proper semantics and we need to be able to overwrite this.

Regards,

Eric.
Tags (2)
1 Reply
RichardWatson
Deactivated User
My suggestion is to live with whatever ArcGIS Server does.  If you change the type for your service then you will return one thing and ArcGIS Server calls, i.e. calls not to your SOE, will return another.  It seems better to me to be consistent even if it is not optimal.  ArcGIS Server does not seem to give you a lot of control over many aspects of the HTTP response.

That said, one solution that will work is to implement a proxy server.  If you have a proxy then you can change anything (including ESRI responses) that you like.
0 Kudos