如何在Web api中将XmlDocument传递给post方法

时间:2016-01-31 03:01:07

标签: asp.net-mvc asp.net-web-api xmldocument

我有一个web api post方法:

------------------------
Condition |  NumMessage
------------------------
          |  80 
Fair      |  20
Good      |  60
Ideal     |  50
Great     |  80

如何使用doCountQuerys <- function(con, table) { query <- paste(' SELECT message_condition Condition, COUNT(message_id) NumMessage FROM`', table, '` GROUP message_condition', sep = '') ts <- dbGetQuery(con, query) return(ts) } lists <- dbListTables(con) # get list of all tables in the database countz <- numeric(0) # store the counts for all tables for (i in 1:length(list)) { counta <- doCountQuerys(con, lists[i]) countz[i] <- counta[[1]] #print(countz[[1]]) } ## Warning in countz[i] <- counta[[1]]: number of items to replace is not a ## multiple of replacement length 传递给此方法? 我尝试了所有的事情,包括:

    [HttpPost]
    [ActionName("LoggerAttachment")]
    public string PostLoggerAttachment([FromBody] XmlDocument doc)
    {
        if (doc == null)
            return "Data is empty";
    }

他们没有工作。

1 个答案:

答案 0 :(得分:0)

我终于发现了什么问题。我应该使用select avg(coalesce(ct, 0)) from book b left join ( select key, count(*) ct from authorcollection group by 1 ) a using (key) where year >= 2000; 代替PostAsJsonAsync。所以以下行对我有用:

PostAsXmlAsync