Copied to clipboard

Flag this post as spam?

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


  • Sören Deger 733 posts 2844 karma points c-trib
    Mar 07, 2015 @ 14:05
    Sören Deger
    0

    401 unauthorized from UmbracoApiController after update to 7.2.2

    Hi all,

    I have a issue with UmbracoApiContoller. I have update from 7.2.1 to 7.2.2 and I get this error message in google chrome console:

    GET: localhost/umbraco/api/mail2cmsApi/receiveMails?mailboxId=1 401 (Unauthorized)

    This works in all versions between 7.1.6 and 7.2.1. Now I have setup a new clean 7.2.2 and I get the same result. Therefore, there can be no error when updating.

    I have no errors found in UmbracoTraceLog.txt. 

    My ApiController beginns with this code and works before 7.2.2:

    public class mail2CmsApiController : UmbracoApiController
        {
            [HttpGet]
            [Umbraco.Web.WebApi.UmbracoAuthorize]
            public int receiveMails(int mailboxId)
            {

    If the error occurs I get redirected to the umbraco login screen. But If I reload the browser I'm already logged in.

    Are there any changes or known issues in 7.2.2?

     

    Best,

    Sören

  • Sören Deger 733 posts 2844 karma points c-trib
    Mar 07, 2015 @ 14:33
    Sören Deger
    101

    The issue is related with this topic:

    https://our.umbraco.org/forum/ourumb-dev-forum/bugs/61943-722-WebApi-UmbracoAuthorize-attribute-always-returns-Authorization-has-been-denied-for-this-request

     

    This post has helped me to solve the problem:

    http://umbraco.com/follow-us/blog-archive/2014/1/17/heads-up,-breaking-change-coming-in-702-and-62

     

    Now I have done the following:

    1. change UmbracoApiController to UmbracoAuthorizedApiController

    2. add the attribute [IsBackOffice] to my ApiControllerClass

    3. add the attribute [PluginController("mail2CMS")] to my ApiControllerClass

    4. change the hardcoded url in my plugin based controller from

    /umbraco/api/mail2cmsApi/receiveMails?mailboxId= 

    to

    backoffice/mail2CMS/mail2CmsApi/receiveMails?mailboxId=

     

    And now it works also in 7.2.2,

     

    Sören

  • 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