How to get site page collection via graph sdk method? - microsoft-graph-api

Tried this:
graphServiceClient
.sites(siteId)
.pages(pageId)
.buildRequest()
.get() but seems earlier pages method was supported and now it's not appearing.
Is there any way to get site page collection?

thanks for reaching out ,I understood that you are trying to get list of sites, looks like you are using async await ,please convert your get() function to GetAync() and add await.
Could you please try by using the below sample code
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var items = await graphClient.Sites["{site-id}"].Lists["{list-id}"].Items .Request()
.GetAsync();
ref docs - https://learn.microsoft.com/en-us/graph/api/listitem-list?view=graph-rest-1.0&tabs=csharp#request
Hope this helps , please let us know if you have any query
thanks

Related

Search Users within Graph API

In my C# application I am trying to search for a User via Graph API. The only parameter I have is the username which is stored in onPremisesSamAccountName field.
Through Graph Explorer I can successfully run the query
https://graph.microsoft.com/v1.0/users?$count=true&$search="onPremisesSamAccountName:myusername"&$select=id,displayName
And Graph Explorer gives me the C# code to use
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var users = await graphClient.Users
.Request()
.Search("onPremisesSamAccountName:myusername")
.Select("id,displayName")
.GetAsync();
Now when I try to use that code I get an error saying that Search is not a method, do I need to add an extra package to use Search?
I also didn't find any nuget package with Search method.
You can specify search value by using query option. $search query parameter requires a request header ConsistencyLevel: eventual
var queryOptions = new List<Option>()
{
new QueryOption("$search", "\"onPremisesSamAccountName:myusername\""),
new HeaderOption("ConsistencyLevel", "eventual")
};
var users = await graphClient.Users
.Request(queryOptions)
.Select("id,displayName")
.GetAsync();

Update Group Photo

Contrary to the documentation on https://learn.microsoft.com/en-us/graph/api/profilephoto-update?view=graph-rest-1.0&tabs=http there is no .Content object available under .Photo.
group.Photo.Content.Request().PutAsync(photoStream).Result;
I am looking to update the profile photo for the group and it does not seam to be available.
Below code is working for me. Can you please try similar way.
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var stream = await graphClient.Groups["groupId"].Photo.Content
.Request()
.GetAsync();
I have installed Microsoft.Graph Nuget version 3.4.0.

C# example through microsoft graph explorer says undefined method

Your c# example for https://graph.microsoft.com/v1.0/me/people?$search="jesper"
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var people = await graphClient.Me.People
.Request()
.Search("jesper")
.GetAsync();
Error I'm getting:
not sure if this is meant to happen but seems wrong that you cant use the search function
https://developer.microsoft.com/en-us/graph/graph-explorer
Yes, you're absolutely right. Those snippets are generated by a tool, and sometimes it gets it wrong. Thanks for reporting!
You can add any query parameters to requests sent by the SDK though, so you can still make this work like so:
var options = new List<QueryOption> { new QueryOption("$search", "j") };
var people = await graphClient.Me.People.Request(options).GetAsync();

Returning Twiml through c#

Trying out something very basic in Twilio & C#. I am new to Twilio & I am not very strong with MVC
public class IncomingCallController : TwilioController
{
// GET: IncomingCall
[HttpGet]
public ActionResult Index()
{
var response = new VoiceResponse();
var dial = new Dial();
Response.ContentType = "text/xml";
response.Say("Please wait...transferring your call");
dial.Number("+919812345678");
return TwiML(response);
}
}
I need the above code snippet to return the static Twiml equivalent that I would have put in a Twiml bin.
I have configured the phone number to with a webhook url as
http://someaddress.azurewebsites.net/IncomingCall
Why am i getting an
11210-HTTP bad host name
error
I understand that I am doing something wrong here. I have tried using both a POST and GET request.
Can anyone who has knowledge of this point me in the right direction?
Where am I going wrong?
Any help would be appreciated.
Some issues are created by programmers who are in a tearing hurry....This was an issue created by yours truly..
Thanks to Phil's interaction I was able to find out...

How does GetExternalLoginInfoAsync() work? (MVC5)

I have a very simple question, some time of Googling didn't give me the answer. I'm using MVC 5 for a project and using OWIN OAuth features for facebook login.
I'm using the recommended way by first creating a challange result:
return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl }));
and in a callback function capturing it with
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
Now my question is, is this the only that this method (GetExternalLoginInfoAsync) works? I need to access the info (loginInfo) provided by this callback later on, should I write this to a db, etc or is there a better way?

Resources