articleabs webrequest方法输出的id,当POST请求成功时,转发createURL metod。但是,我收到以下错误:
错误 - >根级别的数据无效。第1行,第1位。
代码行:
var document = XDocument.Parse(articleABS());
我尝试在createURL方法中添加一个null语句条件,如果article方法的id为空则退出方法,但是这也没有用,我仍然得到错误。
public string createURL()
{
string uri = "";
var document = XDocument.Parse(articleABS());
var href = document.Descendants("link").Single().Attribute("title").Value;
href = href.Replace("Article", "");
string id = Regex.Match(href, @"\d+").Value;
var result = (@"#####" + id + "/sections");
return uri = result.ToString();
}
public string articleABS()
{
var result = (@"####" + mainID + "/articles");
string URL = result;
string method = "POST";
string postData = articleXML.createArticleABS();
try
{
if (hwrequest.Method == "POST")
{
....
}
using (HttpWebResponse hwresponse = (HttpWebResponse)hwrequest.GetResponse())
{
....
}
hwresponse.Close();
}
}
catch (WebException e)
{
.....
else
{
//
}
}
return responseData;
}
articleABS();
的示例输出<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://api.newsweaver.com/nwapistatic/ntsa-api.xsl" type="text/xsl"?>
<?xml-stylesheet href="https://api.newsweaver.com/nwapistatic/ntsa-api.css" type="text/css"?>
<status>
<code>409
</code>
<message>
content.article.required.title null
</message>
</status>
请指教。谢谢