0
votes

--Updated with Stack Trace Error--

I'm struggling trying to get the following code to process correctly:

curl -v -u SD4FWFCF-ASD2-32FD-AF34-F34A4FA4CA34:CO0I0MM0-2349-OIJC-3409-234F098JJ3F4 -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"email":"[email protected]","amountPaid":19.99,"systemName":"test-purchase","recipientPhoneNumber":"5558884321","senderPhoneNumber":"8005551234","deliveryDate":null,"paymentType":5,"scriptValues":[{"key":"fname","value":"john"},{"key":"lname","value":"doe"},{"key":"width","value":"medium"},{"key":"length","value":"large"},{"key":"city","value":"Fairbanks"},{"key":"state","value":"alaska"}]}' -k "https://api.example.com/processorder" -o output.html

Every time I run this, I receive a 500 Internal Server Error.

Here is an example of that error:

Server Error in '/' Application.

Sequence contains no elements

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Sequence contains no elements

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: Sequence contains no elements]
System.Linq.Enumerable.Single(IEnumerable1 source) +371
System.Linq.Queryable.Single(IQueryable
1 source, Expression1 predicate) +590
Example.Web.Areas.Api.Controllers.ApiController.ProcessOrder(JsonProcessOrder model) in C:\Example.Web\Areas\Api\Controllers\ApiController.cs:1221
lambda_method(Closure , ControllerBase , Object[] ) +127
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
2 parameters) +248
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +39
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +125 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continuation) +640
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary2 parameters) +312
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +691
System.Web.Mvc.Controller.ExecuteCore() +162
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +305 Example.Web.DataController.Execute(RequestContext requestContext) in C:\Example.Web\DataController.cs:180
System.Web.Mvc.<>c_DisplayClassb.b_5() +62
System.Web.Mvc.Async.<>c_DisplayClass1.b_0() +20
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375

Version Information: Microsoft .NET Framework Version:4.0.3; ASP.NET Version:4.0.3

I've tried to alter the json, but I can't figure it out for the life of me.

1
Can you show us the code that is throwing that error? Sounds like it's expecting some sort of collection and not finding one.Abe Miessler
Can we see the code for the ProcessOrder method?Abe Miessler
Unfortunately, no. These methods are closed. This is all I can provide to you.ServAce85
Can't tell you much then. It looks like something in that method is trying to call Single on an empty sequence, but without seeing the code it's anyone's guess. Is it possible that you left a required parameter out? Perhaps in scriptValues?Abe Miessler
Yeah, that's what I'm figuring. Oh well. Thanks for the help anyway.ServAce85

1 Answers

0
votes

There's no way to answer this question without knowing more about the methods. There is likely a call to an empty sequence as @Abe Meissler stated.