Copied to clipboard

Flag this post as spam?

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


  • dev-thandabantu 41 posts 321 karma points
    Aug 17, 2022 @ 05:56
    dev-thandabantu
    0

    hit dashboard controller from dashboard.controller.js

    Hi.

    I am creating a custom dashboard for administrators to approve content pending approval in the umbraco backoffice. I have a controller which looks so: controller

    I am trying to hit this controller from my dashboard.controller.js like so: js snippet

    When I run my project, I get a:

    Request error: The URL returned a 404 (not found): /umbraco/api/Dashboard/GetContentPendingApproval

    When I inspect, in the console I get a: console error

    Anyone knows what the issue is here? Would appreciate some assistance, thanks!

  • Patrick de Mooij 73 posts 623 karma points MVP 3x c-trib
    Aug 17, 2022 @ 07:00
    Patrick de Mooij
    100

    Hi,

    This is because your url should be along the lines of this: /umbraco/backoffice/api/{controller}/{action}

    You can find more information about that here: https://our.umbraco.com/documentation/reference/routing/Authorized/

  • dev-thandabantu 41 posts 321 karma points
    Aug 17, 2022 @ 07:54
    dev-thandabantu
    0

    I have updated my url as below and I am still not hitting the breakpoints in my controller. (But the alert on line 42 is working):

    updated js file

    Edit: The response by Patrick de Mooij is the solution, and I have marked it as so. I am not sure why this failed when I first tried it but it is working now after I updated by url to be:

    url: '/umbraco/backoffice/api/Dashboard/GetContentPendingApproval'
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies