0

有谁能够帮我?

此代码无需参数即可正常工作:

private void PopulateGridView()
{
    string apiUrl = apiurl + "local_stud_listgrupmenu";
    
    string inputJson = (new JavaScriptSerializer()).Serialize(input);
    WebClient client = new WebClient();
    client.Headers["Content-type"] = "application/json";
    client.Headers[HttpRequestHeader.ContentType] = "application/json";
    client.Encoding = Encoding.UTF8;
          
    string json2 = client.UploadString(apiUrl,"POST");
    Response.Write("output:" + json2.ToString());
}

但是下面的这段代码使用 post 参数返回 null,我的代码有什么问题:)

private void crudinsert()
{
    string data;
    string apiUrl = apiurl + "ins_rec_crudparentmenu";
    
    string x = "";
    var vm = new { mod = "0", moduldesc ="test'", modulurl = "tesx.aspx", idparent= "0"    };
    
    using (var clien2 = new WebClient())
    {
        var dataString = (new JavaScriptSerializer()).Serialize(vm);
        client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
        x = client.UploadString(new Uri(apiUrl), "POST", dataString);
    }

    Response.Write("output:"+x);
}
4

0 回答 0