0

Can anybody help me?

This code work fine with no parameter:

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());
}

but this code below return null with post parameter, what wrong my code :)

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);
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
atok
  • 1
  • Do you control the API? Maybe you could take a look at the logs. – Jan Köhler Oct 12 '21 at 04:23
  • I can't see anything about your tags: webforms (I read only `PopulateGridView()`); webapi (I read only a request). Two methods have different names so do different things. What does it mean "return null"? Where? I read only `Response.Write()`. Can we look also the API? – Emanuele Oct 14 '21 at 15:41

0 Answers0