/// <inheritdoc /> /// <summary> /// Create a new article Articles are blobs of text with titles, a category and assets. Formatting and display of the text is in the hands of the front end.<br><br><b>Permissions:</b> ARTICLES_ADMIN /// </summary> /// <param name="articleResource">The new article</param> public void CreateArticle(ArticleResource articleResource) { mWebCallEvent.WebPath = "/content/articles"; if (!string.IsNullOrEmpty(mWebCallEvent.WebPath)) { mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json"); } mWebCallEvent.HeaderParams.Clear(); mWebCallEvent.QueryParams.Clear(); mWebCallEvent.AuthSettings.Clear(); mWebCallEvent.PostBody = null; mWebCallEvent.PostBody = KnetikClient.Serialize(articleResource); // http body (model) parameter // authentication settings mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant"); // authentication settings mWebCallEvent.AuthSettings.Add("oauth2_password_grant"); // make the HTTP request mCreateArticleStartTime = DateTime.Now; mWebCallEvent.Context = mCreateArticleResponseContext; mWebCallEvent.RequestType = KnetikRequestType.POST; KnetikLogger.LogRequest(mCreateArticleStartTime, "CreateArticle", "Sending server request..."); KnetikGlobalEventSystem.Publish(mWebCallEvent); }
public IActionResult GetArticleById(string articleId) { if (articleId == null) { return(NotFound()); } var article = new ArticleResource() { Title = "Article - 1", Description = "Testing" }; return(Ok(article)); }
/// <inheritdoc /> /// <summary> /// Update an existing article <b>Permissions Needed:</b> ARTICLES_ADMIN /// </summary> /// <param name="id">The article id</param> /// <param name="articleResource">The article object</param> public void UpdateArticle(string id, ArticleResource articleResource) { // verify the required parameter 'id' is set if (id == null) { throw new KnetikException(400, "Missing required parameter 'id' when calling UpdateArticle"); } mWebCallEvent.WebPath = "/content/articles/{id}"; if (!string.IsNullOrEmpty(mWebCallEvent.WebPath)) { mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json"); } mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "id" + "}", KnetikClient.ParameterToString(id)); mWebCallEvent.HeaderParams.Clear(); mWebCallEvent.QueryParams.Clear(); mWebCallEvent.AuthSettings.Clear(); mWebCallEvent.PostBody = null; mWebCallEvent.PostBody = KnetikClient.Serialize(articleResource); // http body (model) parameter // authentication settings mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant"); // authentication settings mWebCallEvent.AuthSettings.Add("oauth2_password_grant"); // make the HTTP request mUpdateArticleStartTime = DateTime.Now; mWebCallEvent.Context = mUpdateArticleResponseContext; mWebCallEvent.RequestType = KnetikRequestType.PUT; KnetikLogger.LogRequest(mUpdateArticleStartTime, "UpdateArticle", "Sending server request..."); KnetikGlobalEventSystem.Publish(mWebCallEvent); }