All oData Web APIs are broken after importing solution - dynamics-crm

using Dynamics CRM 2016 on premises, after importing an unmanaged solution in an organization (via the Web API Action ImportSolution and then PublishAllXml), all the Web APIs have stopped working, and return the following :
(example : https://MyDynamicsServer/MyOrganization/api/data/v8.0/contacts )
{
"Message": "Object reference not set to an instance of an object.",
"ExceptionMessage": "Object reference not set to an instance of an object.",
"ExceptionType": "System.NullReferenceException",
"StackTrace": " at Microsoft.OData.Edm.ExtensionMethods.AddAlternateKeyAnnotation(EdmModel model, IEdmEntityType type, IDictionary`2 alternateKey)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataModelProvider.DeclareAlternateKeys(EdmEntityType entityType, EntityMetadata entityMetadata, EdmModel edmModel)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataModelProvider.AddEntitiesToModel(ICollection`1 edmEntitySets, EdmModel model, EdmEntityContainer container)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataModelProvider.AddEntities(Dictionary`2 edmModels, Dictionary`2 containers, DynamicMetadataCache cache)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataModelProvider.InitializeEdmModels(DynamicMetadataCache cache)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataModelProvider.GetEdmModel(ModelVisibility requestedEdmType)\r\n at Microsoft.Crm.Extensibility.OData.CrmEdmModel.get_InternalEdmModel()\r\n at Microsoft.Crm.Extensibility.OData.CrmEdmModel.get_EntityContainer()\r\n at Microsoft.OData.Edm.ExtensionMethods.FindDeclaredEntitySet(IEdmModel model, String qualifiedName)\r\n at Microsoft.OData.Edm.ExtensionMethods.FindDeclaredNavigationSource(IEdmModel model, String qualifiedName)\r\n at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.TryCreateSegmentForNavigationSource(String identifier, String parenthesisExpression)\r\n at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.CreateFirstSegment(String segmentText)\r\n at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.ParsePath(ICollection`1 segments)\r\n at Microsoft.OData.Core.UriParser.Parsers.ODataPathFactory.BindPath(ICollection`1 segments, ODataUriParserConfiguration configuration)\r\n at Microsoft.OData.Core.UriParser.ODataUriParser.Initialize()\r\n at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath, ODataUriResolverSetttings resolverSettings, Boolean enableUriTemplateParsing)\r\n at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath)\r\n at System.Web.OData.Routing.ODataPathRouteConstraint.Match(HttpRequestMessage request, IHttpRoute route, String parameterName, IDictionary`2 values, HttpRouteDirection routeDirection)\r\n at System.Web.Http.Routing.HttpRoute.ProcessConstraint(HttpRequestMessage request, Object constraint, String parameterName, HttpRouteValueDictionary values, HttpRouteDirection routeDirection)\r\n at System.Web.Http.Routing.HttpRoute.ProcessConstraints(HttpRequestMessage request, HttpRouteValueDictionary values, HttpRouteDirection routeDirection)\r\n at System.Web.Http.Routing.HttpRoute.GetRouteData(String virtualPathRoot, HttpRequestMessage request)\r\n at System.Web.Http.WebHost.Routing.HttpWebRoute.GetRouteData(HttpContextBase httpContext)",
"ErrorCode": 500
}
This is critical, as it makes our customizations unusable ! (and also prevents us from importing customizations automatically, as this process uses Web API)
Note that the same solution has been imported in another organization the same way without issue ...
The import of the solution through the UI still works, but that completely defeats the point of our automation pipeline ...
Has anyone encountered this issue ? Where should I look ?
(note : I have also posted this question here : https://community.dynamics.com/crm/f/117/t/206996 )

It seems your OData is not enabled or not supported. Please check via
Settings => Customizations => Developer Resources

Related

Unable to remove Dynamics 365 Appointment's Optional and Required flelds value using Web API

I'm trying to remove Required and Optional Parties from an Appointment using Dynamics 365 Web API. I have tried "activityparties" entity to delete the values but no luck.
Request:
DELETE https://xxxxxx.crm.dynamics.com/api/data/v8.2/appointments(EE4C7268-81B7-E811-8143-3863BB368D98)/activitypointer_activity_parties_required(79ea68eb-4304-e911-8147-3863bb2eb450)
Response: 400 Bad Request
{
"error": {
"code": "",
"message": "Request message has unresolved parameters.",
"innererror": {
"message": "Request message has unresolved parameters.",
"type": "Microsoft.Crm.CrmHttpException",
"stacktrace": " at Microsoft.Crm.Extensibility.OData.CrmODataRoutingConvention.SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup`2 actionMap)\r\n at System.Web.OData.Routing.ODataActionSelector.SelectAction(HttpControllerContext controllerContext)\r\n at System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
}
}
Probably a wrong Navigation property issue in request. There’s no activitypointer_activity_parties_required for sure.
Try this: (I haven’t tested it, can test in CRM REST Builder)
DELETE https://xxxxxx.crm.dynamics.com/api/data/v8.2/appointments(EE4C7268-81B7-E811-8143-3863BB368D98)/activitypointer_activity_parties(79ea68eb-4304-e911-8147-3863bb2eb450)
activitypointer_activity_parties
Update:
Looks like we cannot achieve what you want. I played around a bit, nothing worked out but found these. We cannot do anything with ActivityParty records after creation, you have to manipulate them in form script or pre-create plugin itself before stored in DB.
Entity Set Path [organization URI]/api/data/v9.0/activityparties
Base Type crmbaseentity
Display Name Activity Party
Primary Key activitypartyid
Primary Key Attribute partyidname
Operations Supported GET (RetrieveMultiple Only)
Read more
Additional Reference

Set JSON CamelCase per Web API request

Web API uses the Json.Net formatter to serialise its JSON responses which allows you to customise the format of the generated JSON very easily for the entire application at startup using:
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
This allows you resolve the issues between C# syntax preferring PascalCase and javascript based clients preferring camelCase. However setting this globally on the API without taking into consideration who the client request is actually coming from seems to assume that an API will only have 1 type of client and whatever you set for your API is just the way it has to be.
With multiple client types for my API's (javascript, iOS, Android, C#), I'm looking for a way to set the Json.Net SerializerSettings per request such that the client can request their preferred format by some means (perhaps a custom header or queryString param) to override the default.
What would be the best way to set per-request Json.Net SerializerSettings in Web API?
With a bit of help from Rick Strahl's blog post on creating a JSONP media type formatter, I have come up with a solution that allows the API to dynamically switch from camelCase to PascalCase based on the client request.
Create a MediaTypeFormatter that derives from the default JsonMediaTypeFormatter and overrides the GetPerRequestFormatterInstance method. This is where you can implement your logic to set your serializer settings based on the request.
public class JsonPropertyCaseFormatter : JsonMediaTypeFormatter
{
private readonly JsonSerializerSettings globalSerializerSettings;
public JsonPropertyCaseFormatter(JsonSerializerSettings globalSerializerSettings)
{
this.globalSerializerSettings = globalSerializerSettings;
SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/javascript"));
}
public override MediaTypeFormatter GetPerRequestFormatterInstance(
Type type,
HttpRequestMessage request,
MediaTypeHeaderValue mediaType)
{
var formatter = new JsonMediaTypeFormatter
{
SerializerSettings = globalSerializerSettings
};
IEnumerable<string> values;
var result = request.Headers.TryGetValues("X-JsonResponseCase", out values)
? values.First()
: "Pascal";
formatter.SerializerSettings.ContractResolver =
result.Equals("Camel", StringComparison.InvariantCultureIgnoreCase)
? new CamelCasePropertyNamesContractResolver()
: new DefaultContractResolver();
return formatter;
}
}
Note that I take a JsonSerializerSettings argument as a constructor param so that we can continue to use WebApiConfig to set up whatever other json settings we want to use and have them still applied here.
To then register this formatter, in your WebApiConfig:
config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new StringEnumConverter());
config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
config.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local;
config.Formatters.Insert(0,
new JsonPropertyCaseFormatter(config.Formatters.JsonFormatter.SerializerSettings));
Now requests that have a header value of X-JsonResponseCase: Camel will receive camel case property names in the response. Obviously you could change that logic to use any header or query string param you like.

System.Data.DataException error occurred in EntityFramework.dll

I have been following this tutorial Getting Started with Entity Framework 6 Code First using MVC 5.
When I got to the section where I need to run the program and click on Student so that the program would create database I get the following error.
System.Data.DataException was unhandled by user code
HResult=-2146233087
Message=An exception occurred while initializing the database. See the InnerException for details.
Source=EntityFramework
StackTrace:
at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
at System.Data.Entity.Internal.LazyInternalContext.b__4(InternalContext c)
at System.Data.Entity.Internal.RetryAction1.PerformAction(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action1 action)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
at System.Data.Entity.Internal.InternalContext.Initialize()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet1.Initialize()
at System.Data.Entity.Internal.Linq.InternalSet1.GetEnumerator()
at System.Data.Entity.Infrastructure.DbQuery1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at ContosoUniversityFollow.Controllers.StudentController.Index() in c:\Users\Office\Documents\Visual Studio 2013\Projects\ContosoUniversityFollow\ContosoUniversityFollow\Controllers\StudentController.cs:line 21
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.b__36(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End()
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3c()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass45.b__3e()
InnerException: System.Data.Entity.Core.EntityException
HResult=-2146233087
Message=The underlying provider failed on Open.
Source=EntityFramework
StackTrace:
at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectQuery1.<>c__DisplayClassb.b__9()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func1 operation)
at System.Data.Entity.Core.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption)
at System.Data.Entity.Core.Objects.ObjectQuery1..GetEnumerator>b__0()
at System.Lazy1.CreateValue()
at System.Lazy1.LazyInitValue()
at System.Lazy1.get_Value()
at System.Data.Entity.Internal.LazyEnumerator1.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1[TResult](IEnumerable1 sequence)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable1 query, Expression queryRoot)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable1 source)
at System.Data.Entity.Internal.EdmMetadataRepository.QueryForModelHash(Func2 createContext)
at System.Data.Entity.Internal.InternalContext.QueryForModelHash()
at System.Data.Entity.Internal.ModelCompatibilityChecker.CompatibleWithModel(InternalContext internalContext, ModelHashCalculator modelHashCalculator, Boolean throwIfNoMetadata)
at System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean throwIfNoMetadata)
at System.Data.Entity.Database.CompatibleWithModel(Boolean throwIfNoMetadata)
at System.Data.Entity.DropCreateDatabaseIfModelChanges1.InitializeDatabase(TContext context)
at System.Data.Entity.Internal.InternalContext.<>c__DisplayClasse1.<CreateInitializationAction>b__d()
at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
InnerException: System.Data.SqlClient.SqlException
HResult=-2146232060
Message=Cannot open database "ContosoUniversity1" requested by the login. The login failed.
Login failed for user 'Office-PC\Office'.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=11
LineNumber=65536
Number=4060
Procedure=""
Server=(LocalDb)\v11.0
State=1
StackTrace:
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func1 operation)
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation)
at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
InnerException:
I have a hard time trying to fix the problem. I follow everything and even redo it just to make sure I got it right. I don't think I miss any steps. But there is something wrong. If I run the whole sample code, everything works fine.
Any help is appreciated.
Thanks,
Pheap
EDIT:
It was really frustrating for a simple thing that lead to an error like this.
#mmeasor, I just saw that error as well. It cannot connect to database. So that lead me to check the connection.
What happen was that at first I used this connection string:
So EntityFramework created a database file ContosoUniversity1.mdf in here like C:\Users\Office\ContosoUniversity1.mdf. But then I want it to create another one and use that instead and this time I want it to be in the program App_Data\ folder instead.
So I modified the web.config file to:
I thought if I do that, EF will create a new database for me in the \App_Data\ folder and link to that instead of the old on in C:\Users\Office.
I was so wrong! that was when I start getting the error posted above. And I cannot find what causes the problem.
With the second web.config, I tried to copy the database file to the App_Data folder, but that still doesn't work.
Now I use the first connection string and it works fine.
So now the question is: How to make the program links to database file in the \App_Data\ folder instead?
Thanks,
Pheap
I had the same problem in trying to change location of Conosto University tutorial database from User folder to App_Data folder. John Locke keyed me into the idea that it may have something to do with having to change the name of the database.
Change name slightly of database named in the web.config file (This works inconsistently, but does work consistently inconsistently. If I had to test this again...and I'm sure I will at some point...I would stay away from reusing names - i.e. don't toggle back and forth between two name preferences (e.g. database1 and database2 back to database1 - I would use completely novel names e.g. databse7...database8...database9 - get name away from previously used names)
I also had luck, once a database was created with the name I didn't want, changing the database name to what I wanted it to be and matching that name in web.config (i.e. I was able to create a "database3.mdf" file successfully and then changed it in the OS to what I wanted - "database1.mdf" and matched the web.config file to database1 and it connected up on the first try)
I had this problem for days ("An exception of type 'System.Data.DataException' occurred in EntityFramework.dll but was not handled in user code") and I tried everything since changing the connection string to many different methods I saw on Internet questions and answers,
My solution?...
Created a new proyect with another name, and it saved me.
Here EmployeeDetail is a table name and Employee is a model name. And
ID,Branch, Salary and UID are table fields:
public ActionResult Index()
{
List<EmployeeDetail> employees = context.EmployeeDetails.ToList();
List<Employee> emp = new List<Employee>();
foreach(EmployeeDetail item in employees)
{
emp.Add(new Employee
{
ID=Convert.ToInt32(item.ID),
Branch=item.Branch,`enter code here`
Salary=Conve`enter code here`rt.ToInt32(item.Salary),
UID = Convert.ToInt32(item.ID),
});
}
return View(emp);
}
view page code
<div style="font-family:Arial">
<h2>Index</h2>
<ul>
#foreach (var emp in Model)
{
<li>
#Html.ActionLink(emp.Branch, "Details", new { id = emp.ID });
</li>
}
</ul>
</div>

Potentially dangerous Request caused by OutputCache filter

I'm seeing a strange behavior in my MVC3 application. I have an Action that is called by Ajax, and receives a Post with HTML text.
I want to allow the entry of HTML, so I set the ValidateInput(false) attribute. I also have a global OutputCache filter with this parameters: (NoStore = true, Duration = 0, VaryByParam = "*" )
The code looks like this:
[HttpPost]
[ValidateInput(false)]
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*" )]
public ActionResult Edit(SomeModel someModel)
{
saveModel(someModel);
return new AjaxEditSuccessResult();
}
When I send a post to that method, it is executed and the model is saved, but the response I get is the standard "A potentially dangerous Request.Form value was detected from the client" error message, with this stacktrace:
[HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (text="<p class="MsoNormal"...").]
System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection) +9665149
System.Web.<>c__DisplayClass5.<ValidateHttpValueCollection>b__3(String key, String value) +18
System.Web.HttpValueCollection.EnsureKeyValidated(String key) +9664565
System.Web.HttpValueCollection.Get(String name) +17
System.Web.Caching.OutputCacheModule.CreateOutputCachedItemKey(String path, HttpVerb verb, HttpContext context, CachedVary cachedVary) +676
System.Web.Caching.OutputCacheModule.CreateOutputCachedItemKey(HttpContext context, CachedVary cachedVary) +55
System.Web.Caching.OutputCacheModule.OnLeave(Object source, EventArgs eventArgs) +9716788
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
Do you know if I can indicate in any way to the OutputCache attribute that it needs to respect the ValidateInput attribute?
There are two places in the flow where validation is invoked:
on controller method invokation
when rendered result is stored in the cache.
You have fixed first problem with ValidateInputAttribute(false), but looks like cache module is ignoring the NoStore directive and still tries to construct the cache key and before doing that it validates the arguments, to get rid of that specify: Location = System.Web.UI.OutputCacheLocation.None, so that cache module will not even try to do anything. Replace your OutputCache[...] with something like this:
[OutputCache(NoStore = true, Location = System.Web.UI.OutputCacheLocation.None)]

ServiceStack : How to catch errors before written to response

I develop a Rest Service by using ServiceStack.
My model contains a DateTime property and the problem start with it.If a client post/get wrong formatted date value as string , ServiceStack fires an exception "String was not recognized as a valid DateTime."
Stack Trace:
[FormatException: String was not recognized as a valid DateTime.]
System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles) +6364458
ServiceStack.Text.Common.DeserializeBuiltin`1.<GetParseFn>b__b(String value) in C:\src\ServiceStack.Text\src\ServiceStack.Text\Common\DeserializeBuiltin.cs:58
ServiceStack.ServiceModel.Serialization.StringMapTypeDeserializer.PopulateFromMap(Object instance, IDictionary`2 keyValuePairs) in C:\src\ServiceStack\src\ServiceStack.Common\ServiceModel\Serialization\StringMapTypeDeserializer.cs:79
[SerializationException: KeyValueDataContractDeserializer: Error converting to type: String was not recognized as a valid DateTime.]
ServiceStack.ServiceModel.Serialization.StringMapTypeDeserializer.PopulateFromMap(Object instance, IDictionary`2 keyValuePairs) in C:\src\ServiceStack\src\ServiceStack.Common\ServiceModel\Serialization\StringMapTypeDeserializer.cs:95
ServiceStack.ServiceHost.RestPath.CreateRequest(String pathInfo, Dictionary`2 queryStringAndFormData, Object fromInstance) in C:\src\ServiceStack\src\ServiceStack\ServiceHost\RestPath.cs:319
ServiceStack.WebHost.Endpoints.RestHandler.GetRequest(IHttpRequest httpReq, IRestPath restPath) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\RestHandler.cs:104
ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\RestHandler.cs:80
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +625
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270
I know its an error and I know it must be catches but I want to implement it with my error codes and error descriptions(human friendly).
Any advice could be very helpful about how to catch an exception before its written to response itself on (DebeugMode=true) or the service fires an exception to client.
Thnx
Add your Custom Request Binder (or more advanced option is to implement IRequiresRequestStream on your DTOs) to by-pass ServiceStack's deserialization with your own.
More information about this is contained in ServiceStack's wiki documentation

Resources