Json Dropdown Picker with UmbracoAuthorizedApiController
I have created an UmbracoAuthorisedApiController with a method to return the required Json. If I call it directly in a browser, then I get the data as expected.
I suspect this may be due to the it being an UmbracoAuthorisedApiController, as the Json DataSource doesn't pass though any authentication details - perhaps someone will know how to make nuPickers do this ?
Assuming you are using chrome (it should still be possible in other browsers) in dev tools open the network tab. Refresh the page to get updated network information and in the list of requests you should be able to find the failing request.
If you click on the failed request you should be able to view the response which may contain more details than just the fact it was a 500 error :-)
)]
}',
{
"Message": "An error has occurred.",
"ExceptionMessage": "Illegal characters in path.",
"ExceptionType": "System.ArgumentException",
"StackTrace": " at System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(String[] str, Boolean onlyCheckExtras)\r\n at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)\r\n at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)\r\n at System.Web.InternalSecurityPermissions.PathDiscovery(String path)\r\n at System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping)\r\n at System.Web.HttpServerUtility.MapPath(String path)\r\n at nuPickers.Helper.GetDataFromUrl(String url)\r\n at nuPickers.Shared.JsonDataSource.JsonDataSource.GetEditorDataItems(Int32 contextId)\r\n at nuPickers.Shared.JsonDataSource.JsonDataSourceApiController.GetEditorDataItems(Int32 currentId, Int32 parentId, String propertyAlias, Object data)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(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__0.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__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.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>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.<ExecuteActionFilterAsyncCore>d__0.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__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.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>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.<ExecuteActionFilterAsyncCore>d__0.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__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.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>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.<ExecuteActionFilterAsyncCore>d__0.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__2.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__2.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__2.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__1.MoveNext()"
}
I've just worked though an example using the 1.7.0 source code, and this is working, so hopefully it's possible for you to upgrade to 1.7.0 ? (I think this was fixed in 1.6.0)
namespace nuPickers.www.Controllers.Api
{
public class ExampleApiController : UmbracoApiController
{
public ExampleResponse[] GetDropDownListItems([FromUri] string listKey)
{
List<ExampleResponse> response = new List<ExampleResponse>();
Good to hear the drop down is working for you now.
Regarding the NuGet update, were there any errors there to help diagnose this ? (the deployment contents of the each of these packages should be a single dll - perhaps the dll was locked by something ?)
Json Dropdown Picker with UmbracoAuthorizedApiController
I have created an UmbracoAuthorisedApiController with a method to return the required Json. If I call it directly in a browser, then I get the data as expected.
In the DataType config, I set the Url as :
~/umbraco/backoffice/Api/DropdownlistItems/GetDropdownListItems?listKey=PlasticType
JsonPath = $..* Key JSONPath = itemValue Label JSONPath = itemText
However, I get nothing in the dropdown when I use this on a content node.
What am I doing wrong?
Hi Gordon,
I suspect this may be due to the it being an UmbracoAuthorisedApiController, as the Json DataSource doesn't pass though any authentication details - perhaps someone will know how to make nuPickers do this ?
Thanks, Hendy
Hi Hendy,
I changed it to a UmbracoApiController (and changed the path) and it still doesn't work.
I am getting a 500 error in the browser console -
Hi Gordon,
That should work, can you provide any more details about the error ?
Thanks, Hendy
Sorry - how do I get more details / what other details can I give you?
[edit] It says this next to the error :
angular.min.js?cdv=990528626:106
Hi Gordon,
Assuming you are using chrome (it should still be possible in other browsers) in dev tools open the network tab. Refresh the page to get updated network information and in the list of requests you should be able to find the failing request.
If you click on the failed request you should be able to view the response which may contain more details than just the fact it was a 500 error :-)
Nik
Seems to be "illegal characters in path":
OK - it doesn't like the "~" at the start of the URL.
If I enter the full URL then it works, but not if I enter the path as in my original post.
Obviously, I can't enter the full URL as it will change for each environment.
Hi Gordon,
Thanks for that, that sounds like something we can fix :)
Hi Gordon,
Can I ask what version of nuPickers you are using ?
Thanks, Hendy
Version 1.5.3 - via Nuget
Hi Gordon,
I've just worked though an example using the 1.7.0 source code, and this is working, so hopefully it's possible for you to upgrade to 1.7.0 ? (I think this was fixed in 1.6.0)
Label JsonPath: itemText
Thanks, Hendy
I am using Umraco v7.5.11 and .Net Framework 4.5.2.
I'm not sure if there was a reason for installing that specific version of nuPickers - I'll check and upgrade if possible.
[edit] I've just checked the Nuget page and noticed that 1.5.3 was the latest when this project started ... it seems to have moved on pretty quickly!!
The upgrade from 1.5.3 to 1.7 using Nuget didn't work - I had to remove 1.5.3 and then install 1.7
However, now that I have upgraded the dropdown is working as it should.
Good to hear the drop down is working for you now.
Regarding the NuGet update, were there any errors there to help diagnose this ? (the deployment contents of the each of these packages should be a single dll - perhaps the dll was locked by something ?)
I didn't see any errors.
The solution has a "web" project and an "Extensions" project. The DLL in the web project did not update but the extensions project did.
I didn't have time to play around with it, so I uninstalled nuPickers and then reinstalled the latest version.
I am using Visual Studio 2013 Pro and I used the "Manage Nuget packages for solution..." option.
is working on a reply...