DefaultContractResolver not preserving upper case RRS feed

  • Question

  • I have a web API. In that web API, there is a BowtieController. In the BowtieController, there is a method like this:

            public HttpResponseMessage BowtieUniversalSearch(BowtieUniversalSearchRequest parameters)

    We are also using a DefaultContractResolver in WebApiConfig.cs:

    var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();
                jsonFormatter.SerializerSettings.ContractResolver = new DefaultContractResolver();

    In our Javascript, we have a call to BowtieUniversalSearch like this:

                        url: BowtieAPI.ApiRoot + 'Bowtie/BowtieUniversalSearch',
                        data: request,
                        traditional: true
                        .done(function (data) {
                        if (onSuccess) {
                            if (typeof data === 'string') {
                                data = JSON.parse(data);
                        .fail(function (jqXhr, textStatus, errorThrown) {
                        if (onFail) {
                            onFail(jqXhr, textStatus, errorThrown);

    We set "request" as follows:

                    request.ProjectID = Number(this.BowtieDiagram.getProjectId());
                    request.SearchString = searchString;
                    request.SearchForTypes = searchTypes;

    But when it gets through to the BowtieController, the BowtieUniversalSearchRequest parameter is null.

    My colleague believes the problem is with the DefaultContractResolver. He believes it is not preserving the case of the fields in "request" when it converts it to json and back again. So whereas we initialize request as above, it ends up being:


    ...all lower case.

    Is there any way to tell if this is what DefaultContractResolver is doing? Are there any alternative methods that preserve the case of fields in the parameters?
    • Moved by CoolDadTx Thursday, August 10, 2017 6:27 PM ASP.NET related
    Wednesday, August 9, 2017 5:58 PM

All replies

  • https://forums.asp.net/1246.aspx/1?Web+API

    it's where you should post.

    Wednesday, August 9, 2017 6:27 PM