Copied to clipboard

Flag this post as spam?

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


  • Diego 25 posts 156 karma points
    Aug 21, 2023 @ 14:19
    Diego
    0

    Call action in custon Api Controller

    Hello everyone, i need to know how call an action in custom Api Controller. For exemple in this official guide there is a controller called: "BlogsCommentController". Have an action "GetComments"... https://docs.umbraco.com/umbraco-cms/tutorials/getting-started-with-entity-framework-core

    In other part of code, how is the service or other methods, to call this action that have this url: "Umbraco/Api/BlogComments/GetComments" and return a list of comments?

    Thanks in advance.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 21, 2023 @ 14:36
    Huw Reddick
    0

    I'm not sure exactly what you are asking

  • Diego 25 posts 156 karma points
    Aug 21, 2023 @ 14:40
    Diego
    0

    I would like to know how to make a call to a controller (Api Controller), more precisely its action to return the requested values.

  • Diego 25 posts 156 karma points
    Aug 22, 2023 @ 07:04
    Diego
    0

    I'll try to rephrase the question. I created a custom "controller" which has an Action that fetches data from a custom table. I tested the url with Postman and the call works returning a list of elements in json format... Now unlike SurfaceController where I always used "BeginUmbracoForm" to make the call to the controller, how do I make a call to a Controller API with Umbraco? What is the service/interface that provides a method that takes the url as parameter and can I get a list of elements as a result?

  • Johan Reitsma 68 posts 234 karma points MVP
    Aug 22, 2023 @ 09:05
    Johan Reitsma
    100

    I think you need to call the api from C# code. There is not a default way from umbraco to call an API from razor views.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 22, 2023 @ 15:13
    Huw Reddick
    0

    if in a view you would need to use javascript to execute the api method

  • Diego 25 posts 156 karma points
    Aug 22, 2023 @ 09:16
    Diego
    0

    Thank you very much @JohanReitsma.

Please Sign in or register to post replies

Write your reply to:

Draft