Copied to clipboard

Flag this post as spam?

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


  • Shada 55 posts 137 karma points
    Apr 28, 2015 @ 07:41
    Shada
    0

    delphi and umbraco permission

    Hi! I have SurfaceController which returns JsonResult. This controller is available only for authorized members. Now I want to send a get request from a delphi application. Is there a way to pass the authorization? Thanks

  • Alex Skrypnyk 5876 posts 22449 karma points MVP 4x admin c-trib
    Apr 28, 2015 @ 17:19
    Alex Skrypnyk
    0

    Hi Shada,

    Can you show your SurfaceController code ?

    Maybe you have some restriction attibute ?

    Thanks, Alex

  • Shada 55 posts 137 karma points
    Apr 29, 2015 @ 09:26
    Shada
    0

    Alex Skrypnyk, I have action "GetCatalogs" resolution for the role "CertifiedServiceCenters"

     public class ServiceCatalogsController : SurfaceController
         {
       [Authorize(Roles = "CertifiedServiceCenters")]
             [HttpGet]
             public JsonResult GetCatalogs()
             {  .....
              return Json(new { catalogs }, JsonRequestBehavior.AllowGet);
             }
     }
    

    Delphi project:

    function TFrmCatalogs.GetResponseByUrl(const url: string): string;
    var
      lStream: TStringStream;
    begin
      lStream := TStringStream.Create(Result);
      try
        idhtp.Get(url, lStream);
        lStream.Position := 0;
        Result := UTF8Decode(lStream.ReadString(lStream.Size));
      finally
        FreeAndNil(lStream);
      end;
    end;
    

    But of course it doesn't work because I'm not authorized

  • Shada 55 posts 137 karma points
    Apr 29, 2015 @ 12:04
    Shada
    0

    I solved my problem as written here: [https://our.umbraco.org/forum/umbraco-7/developing-umbraco-7-packages/57862-Authentication-to-call-the-WebAPI-by-external-application][1]

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft