400 Error when using .json or .xml in request

165 views
Skip to first unread message

Ryan Mueller

unread,
Oct 22, 2012, 11:25:21 AM10/22/12
to taffy...@googlegroups.com
I'm attempting to implement two formats for my API. JSON is served up by default and works fine when not explicitly denoted in the url.
As soon as I try using .json or .xml in the url, I start getting 400.0 Errors that read "IIS 7.5 Detailed Error - 400.0 - Requested mime type is not supported (.xml)".

This just seams like it should be an IIS issue, but I'm not sure how to troubleshoot further.

The URL used follows this format: https://{domain}/v1/locations.xml?postalcode=75460&token=DBB6BF17093...&reload=true
And it's redirected to: https://{domain}:443/v1/index.cfm/locations.xml?postalcode=75460&token=DBB6BF17093...&reload=true

Here's my code thus far.

Application.cfc
function applicationStartEvent(){
application.anythingToXml = new anythingtoxml.AnythingToXML().init();
}

function configureTaffy()
{
setDebugKey("debug");
setReloadKey("reload");
setReloadPassword(true);
enableDashboard(true);

setDefaultRepresentationClass("v1.resources.customRepresentation");
}

customRepresentation.cfc
<cfcomponent output="false" extends="taffy.core.baseRepresentation">
<cfset variables.anythingToXml = application.anythingToXml />
<cffunction name="getAsJson" access="public" output="false" taffy:mime="application/json" taffy:default="true">
<cfreturn serializeJson(variables.data) />
</cffunction>
<cffunction name="getAsXML" taffy:mime="application/xml" output="false">
<cfreturn variables.AnythingToXML.ToXML(variables.data) />
</cffunction>
</cfcomponent> 

Matt Gersting

unread,
Oct 22, 2012, 11:29:36 AM10/22/12
to taffy...@googlegroups.com
Sounds like the issue where IIS blocks delivery of "unknown" mime types.
This may be of use:

http://blogs.iis.net/bills/archive/2008/03/25/how-to-add-mime-types-with-iis7-web-config.aspx

Ryan Mueller

unread,
Oct 22, 2012, 12:39:08 PM10/22/12
to taffy...@googlegroups.com
Yep, should have mentioned that I've setup the mime maps.
Ryan

Ryan Mueller

unread,
Oct 22, 2012, 12:41:48 PM10/22/12
to taffy...@googlegroups.com
The 400.0 is what causes confusion for me because mime issues from IIS are supposed to be 404.3.

Adam Tuttle

unread,
Oct 22, 2012, 1:22:28 PM10/22/12
to taffy...@googlegroups.com
It's entirely possible that it's a bug. This is something I've seen a lot of recently as I reworked how mime type handling was done. Are you using the BER from GitHub (master branch)? Or the 1.1 release? Or an older release?

Can you provide a zip of your code, simplified as much as possible, but that still contains the error? I'll try it on various builds including my unreleased dev branches and let you know what I find out.

Adam

Ryan Mueller wrote:
            *Application.cfc*


                    function applicationStartEvent(){
                    application.anythingToXml = new
                    anythingtoxml.AnythingToXML().init();
                    }


                function configureTaffy()
                {
                setDebugKey("debug");
                setReloadKey("reload");
                setReloadPassword(true);
                enableDashboard(true);

                setDefaultRepresentationClass("v1.resources.customRepresentation");
                }


            *customRepresentation.cfc*

Ryan Mueller

unread,
Oct 23, 2012, 12:12:56 PM10/23/12
to taffy...@googlegroups.com
Thanks for the offer. Attached is a zip with a simple Taffy environment.
I've included the web.config as well for your review. However, in my install it's located higher in the directory tree.

Ryan
v1_1.zip
Reply all
Reply to author
Forward
0 new messages