Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1315 posts 1553 karma points
    May 17, 2017 @ 10:20
    Gordon Saxby
    0

    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.

    [{
        "itemValue": "1",
        "itemText": "Std Post"
    },
    {
        "itemValue": "2",
        "itemText": "Std Post (By Courier)"
    }]
    

    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?

  • Hendy Racher 859 posts 3822 karma points MVP admin c-trib
    May 17, 2017 @ 10:23
    Hendy Racher
    0

    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

  • Gordon Saxby 1315 posts 1553 karma points
    May 17, 2017 @ 10:42
    Gordon Saxby
    0

    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 -

    https://website.local/umbraco/backoffice/nuPickers/JsonDataSourceApi/GetEditorDataItems?currentId=1326&parentId=1310&propertyAlias=plasticType
    
  • Hendy Racher 859 posts 3822 karma points MVP admin c-trib
    May 17, 2017 @ 10:46
    Hendy Racher
    0

    Hi Gordon,

    That should work, can you provide any more details about the error ?

    Thanks, Hendy

  • Gordon Saxby 1315 posts 1553 karma points
    May 17, 2017 @ 10:48
    Gordon Saxby
    0

    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

  • Nik 1135 posts 4701 karma points MVP 2x c-trib
    May 17, 2017 @ 11:13
    Nik
    1

    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

  • Gordon Saxby 1315 posts 1553 karma points
    May 17, 2017 @ 11:44
    Gordon Saxby
    1

    Seems to be "illegal characters in path":

    )]
    }',
    {
    "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()"
    }
    
  • Gordon Saxby 1315 posts 1553 karma points
    May 17, 2017 @ 11:53
    Gordon Saxby
    0

    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.

  • Hendy Racher 859 posts 3822 karma points MVP admin c-trib
    May 17, 2017 @ 12:28
    Hendy Racher
    0

    Hi Gordon,

    Thanks for that, that sounds like something we can fix :)

  • Hendy Racher 859 posts 3822 karma points MVP admin c-trib
    May 17, 2017 @ 12:32
    Hendy Racher
    0

    Hi Gordon,

    Can I ask what version of nuPickers you are using ?

    Thanks, Hendy

  • Gordon Saxby 1315 posts 1553 karma points
    May 17, 2017 @ 13:05
    Gordon Saxby
    0

    Version 1.5.3 - via Nuget

  • Hendy Racher 859 posts 3822 karma points MVP admin c-trib
    May 17, 2017 @ 13:05
    Hendy Racher
    100

    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)

    • URL: ~/umbraco/Api/ExampleApi/GetDropDownListItems?listKey=PlasticType
    • JSONPath: $..*
    • Key JSONPath: itemValue
    • Label JsonPath: itemText

      namespace nuPickers.www.Controllers.Api
      {
          public class ExampleApiController : UmbracoApiController
          { 
              public ExampleResponse[] GetDropDownListItems([FromUri] string listKey)
              {
                  List<ExampleResponse> response = new List<ExampleResponse>();
      
                  response.Add(new ExampleResponse() { ItemText = "a", ItemValue = "1" });
                  response.Add(new ExampleResponse() { ItemText = "b", ItemValue = "2" });
      
                  return response.ToArray();
              }
      
              public class ExampleResponse
              {
                  [JsonProperty("itemValue")]
                  public string ItemValue {get; set;}
      
                  [JsonProperty("itemText")]
                  public string ItemText { get; set; }
              }
          }
      }
      

    Thanks, Hendy

  • Gordon Saxby 1315 posts 1553 karma points
    May 17, 2017 @ 13:29
    Gordon Saxby
    0

    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!!

  • Gordon Saxby 1315 posts 1553 karma points
    May 17, 2017 @ 13:59
    Gordon Saxby
    0

    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.

  • Hendy Racher 859 posts 3822 karma points MVP admin c-trib
    May 17, 2017 @ 14:09
    Hendy Racher
    0

    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 ?)

  • Gordon Saxby 1315 posts 1553 karma points
    May 17, 2017 @ 14:13
    Gordon Saxby
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft