Azure Web Jobs Throws Azure Storage 404 Not Found - azure-storage

I have webjobs deployed in Azure and it was previously working before but after our latest deployment we are experiencing issues that our webjobs are throwing "Azure Storage Exception".
[03/25/2016 01:38:26 > 5f45b8: SYS INFO] Status changed to Initializing
[03/25/2016 01:38:40 > 5f45b8: SYS INFO] Run script 'ListNet.JobController.exe' with script host - 'WindowsScriptHost'
[03/25/2016 01:38:40 > 5f45b8: SYS INFO] Status changed to Running
[03/25/2016 01:38:41 > 5f45b8: INFO] Found the following functions:
[03/25/2016 01:38:41 > 5f45b8: INFO] ListNet.JobController.Functions.ManualTrigger
[03/25/2016 01:38:41 > 5f45b8: INFO] Executing: 'Functions.ManualTrigger' because This was function was programmatically called via the host APIs.
[03/25/2016 01:41:12 > 5f45b8: ERR ]
[03/25/2016 01:41:12 > 5f45b8: ERR ] Unhandled Exception: Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (404) Not Found. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode, HttpStatusCode actualStatusCode, T retVal, StorageCommandBase`1 cmd, Exception ex)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.WindowsAzure.Storage.Blob.CloudBlobSharedImpl.<DeleteBlobImpl>b__1b(RESTCommand`1 cmd, HttpWebResponse resp, Exception ex, OperationContext ctx)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult)
[03/25/2016 01:41:12 > 5f45b8: ERR ] --- End of inner exception stack trace ---
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.EndDelete(IAsyncResult asyncResult)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass4.<CreateCallbackVoid>b__3(IAsyncResult ar)
[03/25/2016 01:41:12 > 5f45b8: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.Azure.WebJobs.Host.Protocols.PersistentQueueWriter`1.<DeleteAsync>d__6.MoveNext()
[03/25/2016 01:41:12 > 5f45b8: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.Azure.WebJobs.Host.Loggers.CompositeFunctionInstanceLogger.<DeleteLogFunctionStartedAsync>d__e.MoveNext()
[03/25/2016 01:41:12 > 5f45b8: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<TryExecuteAsync>d__1.MoveNext()
[03/25/2016 01:41:12 > 5f45b8: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.Azure.WebJobs.Host.Executors.HeartbeatFunctionExecutor.<TryExecuteAsync>d__0.MoveNext()
[03/25/2016 01:41:12 > 5f45b8: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.Azure.WebJobs.Host.Executors.AbortListenerFunctionExecutor.<TryExecuteAsync>d__0.MoveNext()
[03/25/2016 01:41:12 > 5f45b8: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.Azure.WebJobs.Host.Executors.ShutdownFunctionExecutor.<TryExecuteAsync>d__0.MoveNext()
[03/25/2016 01:41:12 > 5f45b8: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.Azure.WebJobs.JobHost.<CallAsyncCore>d__7.MoveNext()
[03/25/2016 01:41:12 > 5f45b8: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at Microsoft.Azure.WebJobs.JobHost.Call(MethodInfo method)
[03/25/2016 01:41:12 > 5f45b8: ERR ] at ListNet.JobController.Program.Main()
[03/25/2016 01:41:12 > 5f45b8: SYS INFO] Status changed to Failed
[03/25/2016 01:41:12 > 5f45b8: SYS ERR ] Job failed due to exit code -532462766
I looked into this similar issue but I already have these containers on my azure storage:
Azure Web Job-The remote server returned 404
http://i.stack.imgur.com/HkCab.png
Notes
I use manual trigger
I create a default web job and run it successfully

After months of verification I have found out that the cause of this issue is duplicate nuget package dependencies. It turns out that I have multiple nuget package (Newtonsoft.Json) with different versions (e.g: 1.1, 1.2).
On why nuget is doing that, I have no idea.

Related

REST API to Entity "Bill" throwing a 500 System.NullReferenceException

I have a process that uses the REST API to create two bills for a project task. The first bill for a vendor of a particular vendor class always gets created successfully and can be processed normally. The second bill for a vendor of a different vendor class almost always fails, throwing a 500 Internal Server error. They both pass the same data structure to the same function to create the bill and I've compared the JSON that is being marshaled from the structures and passed to the API. It is identical in structure--just the values are different. Here's the body of the response when I get the error:
{
"message": "An error has occurred.",
"exceptionMessage": "Object reference not set to an instance of an object.",
"exceptionType": "System.NullReferenceException",
"stackTrace": " at PX.Api.ContractBased.SystemContracts.V2.RestController.PutEntity(EntityImpl entity, String select, String filter, String expand, String custom)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_1.<GetExecutor>b__3(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"
}
I am logging the JSON that I'm passing to the API call. The strange thing is if I send the same JSON via Postman, it works.
Here's the JSON I'm passing.
{
"note": "Bill for Job Assignment",
"Amount": {
"value": 210
},
"Date": {
"value": "2020-12-28"
},
"DueDate": {
"value": "2021-01-27"
},
"Hold": {
"value": "false"
},
"LocationID": {
"value": "MAIN"
},
"Terms": {
"value": "SCHEDULE"
},
"Type": {
"value": "Bill"
},
"Vendor": {
"value": "V003700"
},
"VendorRef": {
"value": "FC02000029"
},
"Details": [
{
"Branch": {
"value": "EDS"
},
"InventoryId": {
"value": "FEEFORSERVICE"
},
"Project": {
"value": "V000026C000166"
},
"ProjectTask": {
"value": "020000961900029"
},
"Qty": {
"value": 6
},
"UnitCost": {
"value": 35
}
}
],
"custom": {
"Document": {
"AttributeDETAILLOC": {
"type": "CustomStringField",
"value": "1240 Jones Mill Rd"
},
"AttributeENDTIME": {
"type": "CustomStringField",
"value": "00:00"
},
"AttributeJOBDATE": {
"type": "CustomDateTimeField",
"value": "12/27/2020"
},
"AttributeJOBNBR": {
"type": "CustomStringField",
"value": 9619
},
"AttributeOFIDNBR": {
"type": "CustomStringField",
"value": "937"
},
"AttributeOFCREMPNBR": {
"type": "CustomStringField",
"value": "280"
},
"AttributeVENDORID": {
"type": "CustomStringField",
"value": "V003700"
},
"AttributeEMPNAME": {
"type": "CustomStringField",
"value": "Jones, James Earl"
},
"AttributeSTARTTIME": {
"type": "CustomStringField",
"value": "18:00"
}
}
}
}
I'm hoping that there are clues in the stack trace that mean something to somebody more experienced with the Acumatica REST API than I am.
I was able to solve the problem. It turns out the issue was related to some (secret) change in status of the Project Task associated with the bills I was creating. Once I had released one bill, I was unable to create or release another bill. I added a step in between to change the status of the Project Task to "Active" (which it had been before adding the first bill) before releasing the second bill, and it worked.
Yet another undocumented requirement using the REST API. There's an awful lot of guesswork involved, but once you get it all figured out, it works great!

while running Munit getting error "org.mule.runtime.api.exception.DefaultMuleException: Error while parsing script: %dw"

Error
java.lang.RuntimeException: org.mule.runtime.api.exception.DefaultMuleException: Error while parsing script: %dw 2.0
output application/json
fun splitByLoadNumber(aString) = ((aString splitBy "/")[5] splitBy "_")[2]
fun isCancelled(item) = item contains( "CANCELLED" )
var orderedData={ "files-list": payload."files-list" orderBy ((record,index) -> (record.lastModified)) groupBy splitByLoadNumber($.fileName) pluck $ map $[-1] }
---
"files-list":orderedData."files-list" filter !isCancelled($.fileName)
at org.mule.runtime.config.internal.LazyMuleArtifactContext.lambda$applyLifecycle$8(LazyMuleArtifactContext.java:239)
INFO 2020-04-28 16:34:04,122 [munit.01] org.mule.munit.runner.remote.api.server.RunnerServer: Waiting for client connection
at org.mule.runtime.core.internal.context.DefaultMuleContext.withLifecycleLock(DefaultMuleContext.java:510)
sample payload
#[%dw 2.0 output application/json --- { "files-list": [ { "fileName": "abc/out/edm/pallets/input/abc_Load_DB1902717_COMPLETE_20200415155427_115768.xml", "fileSize": 2001, "lastModified": "2020-04-16T12:26:37" }, { "fileName": "abc/out/edm/pallets/input/abc_Load_DB1902718_CANCELLED_20200415155427_115768.xml", "fileSize": 2001, "lastModified": "2020-04-17T12:26:38" } ] }]

Terraform bucket_notification throwing an error

So I followed this link to create a lambda function that is triggered by an s3 event in tf. When I run apply I get keep getting the following error:
module.elb_logs_to_es.aws_s3_bucket_notification.elb_logs_bucket: 1 error(s) occurred:
aws_s3_bucket_notification.elb_logs_bucket: Error putting S3 notification configuration: AccessDenied: Access Denied
Here's my configuration:
resource "aws_lambda_function" "elb_logs_to_es" {
function_name = "send-elb-logs-to-es"
s3_bucket = "xxxxxxxxxxxx"
s3_key = "elb_logs_to_es/elb_to_es.zip"
handler = "elb_to_es.lambda_handler"
role = "${aws_iam_role.elb_logs_role.arn}"
runtime = "python3.6"
}
resource "aws_s3_bucket_notification" "elb_logs_bucket" {
bucket = "xxxxxxxxxxxx"
lambda_function {
lambda_function_arn = "${aws_lambda_function.elb_logs_to_es.arn}"
events = ["s3:ObjectCreated:*"]
}
}
resource "aws_lambda_permission" "elb_bucket_access" {
statement_id = "AllowExecutionFromS3Bucket"
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.elb_logs_to_es.arn}"
principal = "s3.amazonaws.com"
source_arn = "arn:aws:s3:::xxxxxxxxxxxx"
}
resource "aws_iam_role" "elb_logs_role" {
name = "elb_logs_sending_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow"
}
]
}
EOF
}
I also tried changing bucket policy manually to allow the role to PutObject in it but still nothing. Any ideas?

Windows Authentication Docker

I am new to Docker and am currently trying to "convert" one of our applications to .NET Core to get it work inside a docker container.
However, I am struggling to get the windows authentication to work.
I need to read the windows username from the user inside the controller.
When calling
var userName = this.User.Identity.Name;
the result is empty.
My launchSettings.json looks as following:
{
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:57078/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Feedback.WebApi": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:57079/"
}
}
}
I already tried configuring something in the Program.cs and Startup.cs but that did not help either.
When I add
services.AddAuthentication(IISDefaults.AuthenticationScheme);
to the Startup.cs I get following error message:
InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found.
Microsoft.AspNetCore.Authentication.AuthenticationService+ <ChallengeAsync>d__11.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.ChallengeResult+<ExecuteResultAsync>d__14.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+<InvokeResultAsync>d__19.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+<InvokeFilterPipelineAsync>d__17.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+<InvokeAsync>d__15.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Builder.RouterMiddleware+<Invoke>d__4.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+<Invoke>d__7.MoveNext()
Thank you for your help!

How to control presence of OData error details

I'm trying to control the presence of details in error responses from a Web API 2 OData v4 service. When I hit the OData service hosted on my local IIS, I get something like this:
{
"error": {
"code": "Error code",
"message": "Message from exception filter",
"details": [
{
"code": "Detail code",
"message": "Details here"
}
],
"innererror": {
"message": "Exception message here",
"type": "Exception type",
"stacktrace": "Stack trace here"
}
}
}
When I take the same service and deploy it on a remote server, and hit it with the same message, I get this:
{
"error": {
"code": "Error code",
"message": "Message from exception filter"
}
}
I'm guessing that the "innererror" and "details" sections are suppressed because I'm calling the service remotely? I'm happy that the "innererror" section is suppressed - I don't want to leak those details - but I want to expose the "details" section so that I can provide some more feedback on certain errors. Is there a simple way to achieve this?
Thanks!
I was creating my OData error responses using Request.CreateErrorResponse(myHttpStatusCode, myODataError). Looking at the source code of System.Web.Http.OData.Extensions.HttpRequestMessageExtensions.CreateErrorResponse, it appears that if Request.ShouldIncludeErrorDetail is false, then the ODataError is recreated with just the "code" and "message" items. My solution was to create another overload/extension of CreateErrorResponse which accepts a parameter that controls whether the details section should be included:
public static HttpResponseMessage CreateErrorResponse(this HttpRequestMessage request,
HttpStatusCode statusCode, ODataError oDataError, bool includeDetails)
{
if (request.ShouldIncludeErrorDetail())
{
return request.CreateResponse(statusCode, oDataError);
}
else
{
return request.CreateResponse(
statusCode,
new ODataError()
{
ErrorCode = oDataError.ErrorCode,
Message = oDataError.Message,
Details = includeDetails ? oDataError.Details : null
});
}
}
This allows the "innererror" section to be suppressed independently of the "details" section.