Exemple #1
0
        public bool CreatePost(GhostData data)
        {
            HttpClient clientTest = new HttpClient();

            HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Post, "https://nyasaki.dev/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);
        }
Exemple #2
0
 public static string ToJson(this GhostData self) => JsonConvert.SerializeObject(self);