Closed txbrown closed 7 years ago
Why do you need to change it? Doesn't the default handle both XML and JSON depending on what your accepts header is?
With regards to the specific error though, I could do with more info. What is your code for registering your serializer? What solutions have you tried?
@mattbrailsford I wanted all my output to be json so I removed it. I'll remove the config for this and use accept header and see what happens.
this is my webapi.config (somehow cant style whole block as code in github...):
public class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
//format api output to json and indent
config.Formatters.Remove(config.Formatters.XmlFormatter);
config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
}
}
I removed my api config and I still get the issue. I guess this is an underlying issue within my app
And how are you calling WebApiConfig.Register
in relation to the AuthU config?
This is how I have my AppStart:
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
WebApiConfig.Register(GlobalConfiguration.Configuration);
OAuth.ConfigureEndpoint("/oauth/token", new OAuthOptions
{
UserService = new UmbracoMembersOAuthUserService(),
SymmetricKey = "856FECBA3B06519C8DDDBC80BB080553",
AccessTokenLifeTime = 20, // Minutes
AllowInsecureHttp = true // During development only
});
}
Hi. You can try update Newtonsoft.Json to 9.0.1 for Umbraco project. After change in web.config
bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0"
for dependentAssembly "Newtonsoft.Json"
@mattbrailsford gave another try to the package and followed @ievgeniistepanenko tip - it is now working. thanks! the issue can be closed.
@codenakama ahhh, of course. Glad you got it working.
@mattbrailsford I am opening this issue more as a help to solve this problem with AuthU within my side project. AuthU works fine when I dont have my webapi serializing to json but it does this when I change the default webapi serializer to use json and remove xml.
More specifically, this only occurs when we have the attribute decorator
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
or[JsonIgnore]
inOAuthTokenResponse
I have tried following some stackoverflow solutions to similar issues like this but those didnt work for me.
Do you have an idea of what this might be? Thanks!