Join BoxWorks in San Francisco Nov 12-13! Keynotes, product demos, and Box Master Classes. Reserve your spot!

How to send Box-Notifications header with the value off in BOX API .Net??

New post

Comments

5 comments

  • Murtza

     I am not sure if I fully understand your question. Just to clarify, are you asking how to turn turn off email notifications for a specific folder?

    0
    Comment actions Permalink
  • dkalrasam

    Hello Murtza,

                         Thanks for time. I got reference from following link:

    https://docs.box.com/reference#section-suppressing-notifications

    It says about passing a header Box-Notification with a value off.

    I am using box c# api from GIT https://github.com/box/box-windows-sdk-v2 but unable to find any way to pass this header .

     

    Can you suggest?

     

    0
    Comment actions Permalink
  • Murtza

     Thanks for clarifying.

     

    You can add a header by modifying the AddDefaultHeaders method in the BoxResourceManager class. Adding a header in this method will add a header to all requests you make with this SDK to the Box API. Please see the example below.

     

        protected IBoxRequest AddDefaultHeaders(IBoxRequest request)
            {
                request
                    .Header(Constants.RequestParameters.UserAgent, _config.UserAgent);
                    .Header(Constants.RequestParameters.AcceptEncoding, _config.AcceptEncoding.ToString());
                    /// Add a header to suppress notifications
                    .Header("Box-Notifications", "off");
                
                if (!String.IsNullOrWhiteSpace(_asUser))
                    request.Header(Constants.RequestParameters.AsUser, _asUser);
    
                return request;
            }

     

    To follow the conventions of our SDK, you would store the string for the header key in the Constants class and store the string for header value in the BoxConfig class.

    0
    Comment actions Permalink
  • bahushekh

    Thanks Murtza,

                               It is helpful. Although I was assuming that it would be configurable( without rebuilding the lib can be set from code).

     

    Thanks for the help.

    0
    Comment actions Permalink
  • dkalrasam

    Thanks. This is what I was looking for.

    But now after adding this header I am gettting error "Forbidden" while making an API Call..

    e.g. I am using UsersManager.GetEnterpriseUsersAsync call to get all the users in enterprise.

    If I use lib without the box-notification header it works fine but if i add the  header it started returning 'Forbidden"

     

    Is there any other settings required in Box Application.?

    0
    Comment actions Permalink

Please sign in to leave a comment.