Problem updating existing data item...

Mar 21, 2016 at 6:35 PM
I'm currently running DNN v8.1.0 (7) and 2SXC v8.3.6 with angularjs.

I have made a simple app consisting of two data items (foo & bar) with foo having an entity relationship to bar, allowing for a single association.

I'm logged in with a host account, and have not defined any special permissions for any of the 2sxc entities.

I can view, add and delete a foo, however I can't seem to get editing to work. Upon calling svc.server.update(foo) on the client (using code similar to the "TutorialAngularJS-FeedbackFormWithREST" app), I receive an error. When reviewing the DNN Event Viewer, the following exception event is recorded:

AbsoluteURL:/DesktopModules/2sxc/API/app-content/Foo/610
DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke
ExceptionGUID:e7b6480c-4614-48c6-96f8-fcea20e3811f
AssemblyVersion:
PortalId:-1
UserId:-1
TabId:-1
RawUrl:
Referrer:
UserAgent:
ExceptionHash:I5QVc5jtnBqYevZSX51/qQ==
Message:An error occurred while executing the request. Please consult the event log for details.
StackTrace:
InnerMessage:The given key was not present in the dictionary.
InnerStackTrace:
at System.Collections.Generic.Dictionary2.get_Item(TKey key)
at ToSic.Eav.WebApi.EntitiesController.GetEntityOrThrowError(String contentType, Int32 id, Nullable
1 appId) in C:\Projects\eav-server\ToSic.Eav.WebApi\EntitiesController.cs:line 33
at ToSic.SexyContent.WebApi.AppContentController.Create(String contentType, Int32 id, Dictionary2 newContentItem) in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\WebApi\AppContentController.cs:line 312
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary
2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Tracing.ITraceWriterExtensions.d__181.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Tracing.ITraceWriterExtensions.d__18
1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ExceptionFilterResult.d__0.MoveNext()

It should be noted, I can perform all CRUD operations from the 2sxc admin interface.

I can post all the code here if required, or I can provide an export of the app if that aids in troubleshooting.

Thanks in advance for your help!
Coordinator
Mar 22, 2016 at 6:41 AM
I'm guessing you're value-list has keys in it, which don't exist in the target item. We discovered this recently. In the current version this throws an error, in one of the next releases it will just ignore these.

So it's checking if it can find a key from your provided list in the target, and says it can't find it.

That's my guess.
Mar 22, 2016 at 6:54 PM
Edited Mar 22, 2016 at 8:25 PM
Thanks for the response, unfortunately, I don't think that is the problem (unless I'm not understanding correctly, which is always possible).

To add a little more detail, as defined in the Data tab of the Admin interface, the following is the schema for entity Bar:

Title: String

And the following is the schema for entity Foo:

Title: String
Bar: Entity

The data sent for the POST request is as follows:
POST http://xxx.dnndev.me/DesktopModules/2sxc/API/app-content/Foo/610 HTTP/1.1
Host: xxx.dnndev.me
Connection: keep-alive
Content-Length: 59
TabId: 90
Pragma: no-cache
RequestVerificationToken: kwJ2wvmQ0sIVhGyMUW-7TWhZpAtgWqtYUwwiykSscYY_cWmdkXWedaa87yY8ZcrARGKd0HbSNyQqqeq50
Origin: http://xxx.dnndev.me
Debugging-Hint: bootstrapped by 2sxc4ng
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
Content-Type: application/json;charset=UTF-8
Accept: application/json, text/plain, */*
Cache-Control: no-cache
ModuleId: 415
DNT: 1
Referer: http://xxx.dnndev.me/foo
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cookie: .ASPXANONYMOUS=hug7YcU2VTN3vfY-4xPqj2a3bDWE1oS3hH6m4nGduSNrLFCfRAQgZD1-eNzntB6CDSjXwFhXS4c9rZ_UFJn8UpErwf7nlprholnkBUqMejamFUYS0; __RequestVerificationToken=SFYhhyAWRD515jCpxYHtN_Wfq79dlaw-j8WOTxlr0N-XmJJxpyX_w63AHRG5DEPXGbxu4Q2; USERNAME_CHANGED=; authentication=DNN; .DOTNETNUKE=9340D696BFF7CEB93156D3CC30CD579E1D55B2075A53BBDF53FABFFBF8BEC65F77D004A4EC4131915D97084BC3FA5A42B080A8C68B726EDE826E81C0B5925A8372EF19DC916EFF89E6F3AE3D; LastPageId=0:90; StayInEditMode=NO; dnn_IsMobile=False; language=en-US

{"Guid":"b6111a07-397e-412c-8225-a43ee0ddbb38", "Id":610,"Title":"Foo8","Bar":[{"Id":598,"Title":"Bar1"}]}
I've tried removing the "Title" property from the Bar object, leaving only the "Id" property, as well as removing it from the array, thereby sending only the Bar object as the value for Foo.Bar (with and without the "Title" property). I've also tried calling svc.server.update, with the addition of the id as the second parameter.

None of these variations have worked, and all resulted in the same exception, indicated above.

I have another DNN installation v07.04.02 (216), running 2sxc v7.2.3 and a POST request with the same JSON structure as above, updates the database without error.

Once again thank you for taking the time to respond.