Make POST() With JSON



我正在学习JSON,无法弄清楚下一步。我已经创建了一个JSON阅读器,并将我需要的数据添加到了读者中,但是现在如何使用数据进行帖子()请求?

这就是我拥有的

private void PerformJSONPost()
{
    var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://requestb.in/12frf661");
    httpWebRequest.ContentType = "application/json";
    httpWebRequest.Method = "POST";
    var jsonReader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(@"{ ""Security"": { ""UsernameToken"": { ""Username"": ""redrobin"", ""Password"": ""fahidsma!"" } }"), new System.Xml.XmlDictionaryReaderQuotas());
}

编辑
该语法的问题是唯一发布的内容是:

System.Runtime.Serialization.Json.XmlJsonReader
        var request = WebRequest.CreateHttp(myUrl + "/" + uri);
        request.Credentials = new NetworkCredential(myUserName, myPassword, myDomain);
        request.ContentType = "application/json; charset=utf-8";
        request.Method = "POST";
        using (StreamWriter streamWriter = new StreamWriter(request.GetRequestStream()))
        {
            string jsonstring = JsonConvert.SerializeObject(myJsonobject, Formatting.Indented);
            streamWriter.Write(jsonstring);
            streamWriter.Flush();
        }

在上面看

相关内容

  • 没有找到相关文章

最新更新