-
-
Save komainu85/d3dc939c7c67b9292a28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net; | |
using System.Net.Http; | |
using System.Text; | |
namespace ItemServiceConsoler | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// Note HTTPS required for authentication | |
var baseAddress = new Uri("https://sc80rev150223"); | |
using (var client = new HttpClient() { BaseAddress = baseAddress }) | |
{ | |
// Only enable ServerCertificateValidationCallback if doing local testing. It will ignore certificate validation | |
//ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; | |
var content = new StringContent( | |
@"{ ""domain"": ""sitecore"", ""username"": ""admin"", ""password"": ""b"" }", | |
Encoding.UTF8, | |
"application/json"); | |
var authResult = client.PostAsync("sitecore/api/ssc/auth/login", content).Result; | |
Console.WriteLine(authResult.StatusCode); | |
Console.ReadLine(); | |
var itemResult = client.GetAsync("sitecore/api/ssc/item/{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}").Result; | |
Console.WriteLine(itemResult.StatusCode); | |
Console.WriteLine(itemResult.Content.ReadAsStringAsync().Result); | |
Console.ReadLine(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment