How do I create a batch request to collect the object ids of a list of users?
var roomMail = room.EmailAddress;
var roomUser = await graphClient.Users[roomMail].Request().GetAsync();
var aadObjectId = roomUser.Id;
Related
I have the following code to find the count of users in AAD group:
var requestUrl = _graphClient.Groups[objectId.ToString()].TransitiveMembers.Request().RequestUrl;
requestUrl = $"{requestUrl}/microsoft.graph.user/$count";
var hrm = new HttpRequestMessage(HttpMethod.Get, requestUrl);
hrm.Headers.Add("ConsistencyLevel", "eventual");
await _graphServiceClient.AuthenticationProvider.AuthenticateRequestAsync(hrm);
var r = await _graphServiceClient.HttpProvider.SendAsync(hrm);
var content = await r.Content.ReadAsStringAsync();
var userCount = int.Parse(content);
return userCount;
Is there a way to find out the resource units used for this request (https://learn.microsoft.com/en-us/graph/throttling-limits)
According to the documentation, the resource unit cost for GET groups/{id}/transitiveMembers is 5.
But using $count affects the cost. If you send the request
GET https://graph.microsoft.com/v1.0/groups/{group_id}/transitivemembers/microsoft.graph.user/$count
and check the response headers there should be header x-ms-resource-unit which indicates the resource unit cost used for this request and it's 1.
Get header x-ms-resource-unit
var r = await _graphServiceClient.HttpProvider.SendAsync(hrm);
var cost = r.Headers.GetValues("x-ms-resource-unit").FirstOrDefault();
is there any way to make an HTTP request inside a Zeppelin paragraph? e.g.
function get_app_name(){
//var xmlHttp = new XMLHttpRequest();
//xmlHttp.open( "GET", "https://example.com/application/key", true, 'username', 'password');
//xmlHttp.send( null );
URL url = new URL("https://example.com/application/key");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
}
I cannot import any of the resources (e.g. URL) because the interpreter doesn't allow it (mongodb interpreter). Is there any way to make a simple GET request in Zeppelin? I'm trying to fetch data for my tables that is not in the specified db as the other elements.
From HTTP request inside MongoDB
%mongodb
function wget(url){
var tmp = "/tmp";
var id = new ObjectId();
var outFile= tmp+"/wget"+id;
var p = run("wget", "--user=user", "--password=password", "-o log", "--output-document="+outFile,url);
if (p==0){
var result = cat(outFile);
removeFile(outFile);
return result;
} else {
return "";
}
}
url = "https://exampleurl.com/resource"
result = wget(url)
print(result)
When I upload file I get internalId as response.
My requirement is to get fileURL.
Eg: to get internalId ((RecordRef)(writeRes.baseRef)).internalId))
Is there any way to get fileURL after uploading?
You need to send a new request to get the file once it's uploaded:
var internalId = ((RecordRef)(writeRes.baseRef)).internalId));
RecordRef file = new RecordRef();
recordRef.internalId = internalId;
recordRef.type = RecordType.file;
recordRef.typeSpecified = true;
ReadResponse response = service.get(recordRef);
File file = (File)(response.record);
var fileUrl = file.url;
How do you initialize a NotificationController in DNN 7.1.2?
I've tried:
var nc = new DotNetNuke.Services.Social.Notifications.NotificationController();
However this is empty and has no methods to call... Am I initializing the wrong thing?
Surely there should be something in there other than ToString, GetType, Equals and GetHashCode
I need to be able to create NotificationTypes and create Notifications.
Thanks
You can use NotificationsController.Instance.SendNotification method to send notifications.
Here is the example:
var notificationType = NotificationsController.Instance.GetNotificationType("HtmlNotification");
var portalSettings = PortalController.GetCurrentPortalSettings();
var sender = UserController.GetUserById(portalSettings.PortalId, portalSettings.AdministratorId);
var notification = new Notification {NotificationTypeID = notificationType.NotificationTypeId, Subject = subject, Body = body, IncludeDismissAction = true, SenderUserID = sender.UserID};
NotificationsController.Instance.SendNotification(notification, portalSettings.PortalId, null, new List<UserInfo> { user });
This will send notification to a specific user.
If you need to create your own Notification type use the code below as a guide, it will create a NotificationType "GroupApprovedNotification". This is from core groups module.
type = new NotificationType { Name = "GroupApprovedNotification", Description = "Group Approved Notification", DesktopModuleId = deskModuleId };
if (NotificationsController.Instance.GetNotificationType(type.Name) == null)
{
NotificationsController.Instance.CreateNotificationType(type);
}
I'm trying to collect my url and the description of the url stored in a column of a list from sharepoint and i don't know how to collect the URL value.
This is my code :
var queryResultSaleListItems = clientContext.LoadQuery(listData);
clientContext.ExecuteQuery();
//Read the Data into the Object
var TipsList = from Tips in queryResultSaleListItems
select Tips;
ObservableCollection<Tips> colTips = new ObservableCollection<Tips>();
//Read Every List Item and Display Data into the DataGrid
foreach (SPSClient.ListItem item in TipsList)
{
var tips = new Tips();
tips.TitleTip = item.FieldValues.Values.ElementAt(1).ToString();
tips.App = item.FieldValues.Values.ElementAt(4).ToString();
//should collect the url
tips.URL = item.FieldValues.Values.ElementAt(5).ToString();
//should collect the description of the url
tips.URLdesc = item.FieldValues.Values.ElementAt(5).ToString();
colTips.Add(tips);
}
ListboxTips.DataContext = colTips;
In my expression its >
((Microsoft.SharePoint.Client.FieldUrlValue)(item.FieldValues.Values.ElementAt(5))).Url
((Microsoft.SharePoint.Client.FieldUrlValue)(item.FieldValues.Values.ElementAt(5))).Description
Thanks for your help,
Use FieldUrlValue for getting hyperlink field in Client Object Model.
Use Following Code:
string server = "siteURL";
var ctx = new ClientContext(server);
var web = ctx.Web;
var list = web.Lists.GetByTitle("CustomList");
var listItemCollection = list.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(listItemCollection);
ctx.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem listItem in listItemCollection)
{
string acturlURL = ((FieldUrlValue)(listItem["URL"])).Url.ToString(); // get the Hyperlink field URL value
string actdesc = ((FieldUrlValue)(listItem["URL"])).Description.ToString(); // get the Hyperlink field Description value
}