How to send Box-Notifications header with the value off in BOX API .Net??
How to send Box-Notifications header with the value off in BOX API .Net
Hi,
I am making administrative API calls to download the box files, and the user signing in is a co-admin with the correct "Edit settings for your company" permission and I want to suppress email notifications.
I am making Box API call (in C#) as mentioned below
BoxSession boxsession = new BoxSession("AccessToken","RefreshToken","ExpiresIn","TokenType")
BoxConfig Config = new BoxConfig(ClientId, ClientSecret, RedirectUri) { AcceptEncoding = CompressionType.gzip };
BoxClient Client = new BoxClient(Config, boxSession);
Stream stream = await Client.FilesManager.DownloadStreamAsync(fileId)
Query: how to send Box-Notifications header with above request???
Thanks in advance.
-
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?
-
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.
-
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.?
サインインしてコメントを残してください。
コメント
5件のコメント