Beispiel #1
0
        public bool CreatePost(GhostData data, string url)
        {
            HttpClient clientTest = new HttpClient();

            HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Post, url + "/ghost/api/v3/admin/posts/?source=html"); //with ?source=html mobiledoc is not neccessary

            var serializedJson = Serialize.ToJson(data);

            httpRequest.Content = new StringContent(serializedJson, Encoding.UTF8, "application/json");
            httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Ghost", AuthToken);

            var response = clientTest.SendAsync(httpRequest).Result;

            return(response.IsSuccessStatusCode);
        }
 public static string ToJson(this GhostData self) => JsonConvert.SerializeObject(self);