Skip to content

Instantly share code, notes, and snippets.

@komainu85
Forked from herskinduk/ItemServiceConsoler.cs
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komainu85/d3dc939c7c67b9292a28 to your computer and use it in GitHub Desktop.
Save komainu85/d3dc939c7c67b9292a28 to your computer and use it in GitHub Desktop.
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