我尝试在openbravo中向json发布帖子,响应为(null)?

时间:2019-09-10 17:06:29

标签: c# json restsharp openbravo

我想在openbravo中为json添加数据,但响应为Null

这是供xamarin中的应用使用Openbravo Web服务

public void PostDataProyInf()
{
    string urlBase = servInf + "/org.openbravo.service.json.jsonrest/cpm_daily_serv_rep";
    IRestClient clients = new RestClient(urlBase);
    clients.Authenticator = new HttpBasicAuthenticator(USname, USpass);
    IRestRequest request = new RestRequest(Method.POST);
    request.RequestFormat = DataFormat.Json;
    request.AddHeader("Content-Type", "application/json");
    //request.AddHeader("Accept", "*/*");
    DateTime date = new DateTime();
    date = DateTime.Now;
    date.ToString("yyyy-MM-ddThh:mm:ss-hh:mm");
    string workingT = Horas().ToString() + " " + "hour(s)" + "  " + Minutes().ToString() + " min(s)";

    var daily = " {    \"data\":       {        \"_identifier\":\"" + proytS.Text + "\",        \"_entityName\":\"cpm_daily_serv_rep\",  \"$ref\":\"cpm_daily_serv_rep\",    \"id\":\" \",    \"client\":\"A9D216F4A8894012A48E168268A3D6C9\",  \"client$_identifier\":\"Geosoft\",     \"organization\":\"F14745C58DC74BA38A0F0C85A3C12E74\",      \"organization$_identifier\":\"Geosoft Escencial\",     \"active\":true,        \"creationDate\":\"" + date.ToString() + "\",       \"createdBy\":\"" + IdUser + "\",       \"createdBy$_identifier\":\"" + USname + "\",       \"updated\":\"" + date.ToString() + "\",        \"updatedBy\":\"" + IdUser + "\",       \"updatedBy$_identifier\":\"" + USname + "\",       \"equipInstCctv\":" + eqCCTV.Checked + ",       \"equipInstContAcc\":" + eqContAcc.Checked + ",     \"equipInstDetSuspInc\":" + eqIncend.Checked + ",       \"equipInstTelec\":" + eqTelec.Checked + ",     \"equipInstElecGnral\":" + eqEleG.Checked + ",      \"equipInstMatGnral\":" + eqMatGen.Checked + ",     \"equipInstGnral\":" + eqGeneral.Checked + ",       \"soporteria\":" + soport.Checked + ",      \"canalizacion\":" + canal.Checked + ",     \"cableado\":" + cableado.Checked + ",      \"pruebas\":" + prueba.Checked + ",     \"etiquetado\":" + etiquet.Checked + ",     \"equipo\":" + equipo.Checked + ",      \"project\":\"" + IdTempProy + "\",     \"project$_identifier\":\"" + proytS.Text + "\",        \"actvGeofDesc\":\"" + actEmpInfo.Text + "\",       \"actvClientDesc\":\"" + actEmpInfo.Text + "\",     \"retrabajos\":\"" + retrabS.Text + "\",        \"otros\":null,     \"notasMatFalt\":\"" + matFalInfo.Text + "\",       \"tiempo\":0,       \"cantInstSop\":null,       \"cantInstCab\":null,       \"cantInstPruebas\":null,       \"cantInstEtiq\":null,      \"cantInstEquipo\":null,        \"cantInstCan\":null,       \"workArea\":\"" + areTraInfo.Text + "\",       \"currentDate\":\"" + date.ToString() + "\",        \"entryDate\":\"" + fechaIniInfo.Text + "\",        \"oUTDate\":\"" + fechaFinInfo.Text + "\",      \"entryHour\":\"" + horaIniInfo.Text + "\",     \"oUTHour\":\"" + horaFinInfo.Text + "\",       \"expenseLine\":null,       \"expenseLine$_identifier\":null,       \"activity\":\"" + activiS.Text + "\",  \"meetingClients\":" + junta.Checked + ",       \"lifting\":false,      \"supervision\":" + superv.Checked + ",     \"engineeringDevelopment\":" + desIng.Checked + ",      \"image\":null,     \"image$_identifier\":null,     \"workingTime\":\"" + workingT + "\",       \"importServicesProject\":null,     \"cuopgCreateInstallations\":null,      \"projectPhase\":null,      \"addtools\":null,      \"recordTime\":null}}" ;

    //string jsonesca = JsonConvert.SerializeObject(daily);
    request.AddParameter("application/json", daily, ParameterType.RequestBody);
    //request.AddJsonBody(daily);

    IRestResponse resp = clients.Execute(request);
    var content = resp.Content; // raw content as string

    if (resp.StatusCode == HttpStatusCode.OK)
    {
        Toast.MakeText(this.Context, resp.Content, ToastLength.Long).Show();
    }
    else
    {
        Toast.MakeText(this.Context, "Not Conection Response!!!", ToastLength.Long).Show();
    }
}

我希望Web服务能够正确响应。

0 个答案:

没有答案
相关问题