コード例 #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);
        }
コード例 #2
0
ファイル: Serialize.cs プロジェクト: MarcelWalk/GhostEdit
 public static string ToJson(this GhostData self) => JsonConvert.SerializeObject(self);