How do I provide credentials and domain name to httpWebRequest or httpClient or webClient to download a video from SharePoint url.
Depends on what credentials you need exactly, but you can add Cookies and Custom Headers to any of those three. Here's an example using HttpClient:
HttpClient
public async Task<string> PostJsonDataAsync(string url, string json, bool authorize = true) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(Urls.BASE_ADDRESS); // custom address client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); if (authorize) { // add the bearer token client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", App.Current.CurrentUserStore.Token.AccessToken); } var result = await client.PostAsync(url, new StringContent(json, Encoding.UTF8, "application/json")); return await HandleResponse(result); } }
@mainprashant89 Check here for basic auth and token based auth.
Answers
Depends on what credentials you need exactly, but you can add Cookies and Custom Headers to any of those three.
Here's an example using
HttpClient
:@mainprashant89 Check here for basic auth and token based auth.