dotnetnuke2sxcdnn9

How to access 2sxc API from external non DNN website


I am trying to access a 2sxc api using postman but is not working for some reason.

$2sxc(moduleContext)
      .webApi.get('app/auto/api/List/persons')

I am using [Domain]/DesktopModules/api/2sxc/counterApp/List/persons

But I get a 404 error.

Using $2sxc does work. But I want to make a call from a non DNN-website. The code: Foto: 2sxc api controller


Solution

  • Are you inside the Content App or your own custom app?

    If you are in the Content App, there automagic path is

    https://example.com/DesktopModules/2sxc/api/app/content/content/Person
    |------------------ root -------------------|- app/id --|-part--|--type
    

    The above should just work without writing code (a controller).

    If you're in your own custom app, then you will have written your own custom controller. Which you can read about here, ASP.net WebAPI in 2sxc. In the fake example, below that would be in Portals/0/2sxc/myapp/api/PublicController.cs

    https://example.com/api/2sxc/app/myapp/api/public/persons
    |------------------ root ----|-app/id--|-controller|-function