繁体   English   中英

从WP8提交到webapi时Json响应中的异常

Exception in Json response when Submitting to webapi from WP8

提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供   中文繁体   英文版本   中英对照 版本,有任何建议请联系yoyou2525@163.com。

当我尝试将数据发送到Web api时出现问题,它给出异常HRESULT E_FAIL已从对COM组件的调用返回

System.Net.Browser.ClientHttpWebRequest上的System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult).System.Net.Browser.AsyncHelper上的System.Net.Browser.ClientHttpWebRequest。<> c__DisplayClass1.b__0(对象sendState)

在响应HttpResponseMessage响应=等待client.GetAsync(String.Format(url,Isexist,jsontalleyHeader.ToString(),jsontalleydetail.ToString()));

WP8方法

  public async Task<string> POSTtalleyDetails(bool Isexist, int count)
            { 
                string val = "";
                if ((Isexist == false))//first time Load started--need headerNo               
                {

                    try
                    {

                        using (HttpClient client = new HttpClient())
                        {



                            var valjsontalleyHeader = listRtnTalleySheetHeader;
                            var jsontalleyHeader = Newtonsoft.Json.JsonConvert.SerializeObject(valjsontalleyHeader);

                            var valtalleydetail = listRtnTalleySheetDetail;
                            var jsontalleydetail = Newtonsoft.Json.JsonConvert.SerializeObject(valtalleydetail);


                            client.BaseAddress = new Uri("http://service:Port");
                            var url = "api/config/InsertTalleydetail?Isexist={0}&talleyheaderlist={1}&talleydetails={2}";
                            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                            HttpResponseMessage response = await client.GetAsync(String.Format(url, Isexist, jsontalleyHeader.ToString(), jsontalleydetail.ToString()));

                            if (response.IsSuccessStatusCode)
                            {
                                val = "Ok";
                            }
                            else
                            {
                                val = "No";                  
                            }

                        }

                        return val;

                    }

                    catch (Exception ex)
                    {

                        ex.ToString(); return val = "No";
                    }

                    //
                }
}

jsontalleydetail将在哪里

[{"_Isedited":true,"_CreatedBy":"tc1","_visitID":"VISIT0001783","_Remark":"","_Syncable":true,"_ID":"VISIT0001783","_ItemName":"Aeroplane (M) Flour 50Kg","_TalleySheetDetailNo":"39.0D39.053000","_TalleySheetHeaderNo":"T2H1.033000","_ItemMasterId":33,"_WareHouseId":2,"_ManufacturedDate":"2018-09-25T00:00:00+05:30","_LoadingTypeId":7,"_LoadingDate":"2018-09-25T16:51:53.7504239+05:30","_ConfirmedHatti":7,"_HattiId":1,"_HattiQty":5,"_HattiWeight":0},{"_Isedited":true,"_CreatedBy":"tc1","_visitID":"VISIT0001783","_Remark":"","_Syncable":true,"_ID":"VISIT0001783","_ItemName":"Aeroplane (M) Flour 50Kg","_TalleySheetDetailNo":"40.0D40.053000","_TalleySheetHeaderNo":"T2H1.033000","_ItemMasterId":33,"_WareHouseId":2,"_ManufacturedDate":"2018-09-25T00:00:00+05:30","_LoadingTypeId":7,"_LoadingDate":"2018-09-25T16:51:53.8672939+05:30","_ConfirmedHatti":7,"_HattiId":2,"_HattiQty":1,"_HattiWeight":0},{"_Isedited":true,"_CreatedBy":"tc1","_visitID":"VISIT0001783","_Remark":"","_Syncable":true,"_ID":"VISIT0001783","_ItemName":"Aeroplane (M) Flour 50Kg","_TalleySheetDetailNo":"41.0D41.054000","_TalleySheetHeaderNo":"T2H1.033000","_ItemMasterId":33,"_WareHouseId":2,"_ManufacturedDate":"2018-09-25T00:00:00+05:30","_LoadingTypeId":7,"_LoadingDate":"2018-09-25T16:51:54.0238698+05:30","_ConfirmedHatti":7,"_HattiId":3,"_HattiQty":2,"_HattiWeight":0},{"_Isedited":true,"_CreatedBy":"tc1","_visitID":"VISIT0001783","_Remark":"","_Syncable":true,"_ID":"VISIT0001783","_ItemName":"Aeroplane (M) Flour 50Kg","_TalleySheetDetailNo":"42.0D42.054000","_TalleySheetHeaderNo":"T2H1.033000","_ItemMasterId":33,"_WareHouseId":2,"_ManufacturedDate":"2018-09-25T00:00:00+05:30","_LoadingTypeId":7,"_LoadingDate":"2018-09-25T16:51:54.1564773+05:30","_ConfirmedHatti":7,"_HattiId":4,"_HattiQty":5,"_HattiWeight":0},{"_Isedited":true,"_CreatedBy":"tc1","_visitID":"VISIT0001783","_Remark":"","_Syncable":true,"_ID":"VISIT0001783","_ItemName":"Aeroplane (M) Flour 50Kg","_TalleySheetDetailNo":"43.0D43.054000","_TalleySheetHeaderNo":"T2H1.033000","_ItemMasterId":33,"_WareHouseId":2,"_ManufacturedDate":"2018-09-25T00:00:00+05:30","_LoadingTypeId":7,"_LoadingDate":"2018-09-25T16:51:54.2542986+05:30","_ConfirmedHatti":7,"_HattiId":5,"_HattiQty":2,"_HattiWeight":0},{"_Isedited":true,"_CreatedBy":"tc1","_visitID":"VISIT0001783","_Remark":"","_Syncable":true,"_ID":"VISIT0001783","_ItemName":"Aeroplane (M) Flour 50Kg","_TalleySheetDetailNo":"44.0D44.054000","_TalleySheetHeaderNo":"T2H1.033000","_ItemMasterId":33,"_WareHouseId":2,"_ManufacturedDate":"2018-09-25T00:00:00+05:30","_LoadingTypeId":7,"_LoadingDate":"2018-09-25T16:51:54.3582527+05:30","_ConfirmedHatti":7,"_HattiId":6,"_HattiQty":1,"_HattiWeight":0},{"_Isedited":true,"_CreatedBy":"tc1","_visitID":"VISIT0001783","_Remark":"","_Syncable":true,"_ID":"VISIT0001783","_ItemName":"Aeroplane (M) Flour 50Kg","_TalleySheetDetailNo":"45.0D45.054000","_TalleySheetHeaderNo":"T2H1.033000","_ItemMasterId":33,"_WareHouseId":2,"_ManufacturedDate":"2018-09-25T00:00:00+05:30","_LoadingTypeId":7,"_LoadingDate":"2018-09-25T16:51:54.4742785+05:30","_ConfirmedHatti":7,"_HattiId":7,"_HattiQty":2,"_HattiWeight":0}]

和jsontalleyHeader将是

 [{"_Remark":"","_TsStartTime":"2018-09-25T16:51:54.4742785+05:30","_TsEndDatetime":"0001-01-01T00:00:00","_VisitID":"VISIT0001783","_Approxweight":18.0,"_WHId":2,"_TalleySheetHeaderNo":"T2H1.033000","_Isedited":false,"_CreatedBy":null,"_visitID":null,"_Syncable":false,"_ID":null,"_ItemName":null,"_TalleySheetDetailNo":null,"_ItemMasterId":0,"_WareHouseId":0,"_ManufacturedDate":"0001-01-01T00:00:00","_LoadingTypeId":null,"_LoadingDate":"0001-01-01T00:00:00","_ConfirmedHatti":null,"_HattiId":null,"_HattiQty":null,"_HattiWeight":0}]

我的Web API方法是

 [HttpPost]         
      public HttpResponseMessage InsertTalleydetail([FromBody]List<clsTalleySheetHeader> talleyheaderlist, List<clsTalleySheetDetail>talleydetails)
            {
                return todoService.InsertTalleydetail(talleyheaderlist, talleydetails);
                    //base.BuildSuccessResult(HttpStatusCode.OK, StartTimeDetails);
            }

我相信这是因为由于数据负载,因为它在2到3个jsontalleydetail中可以正常工作。

如果有人可以在这方面给我建议,那将是很大的帮助。

我被回答了类似的问题https://stackoverflow.com/questions/52202989/json-value-doesnt-assign-to-the-list-httppost

问题暂未有回复.您可以查看右边的相关问题.
1 将WP8应用程序提交到Windows应用商店时,如何上传隔离存储文件?

我正在WP8应用程序开发的最后阶段,我很期待提交该应用程序。 但是,我对如何提交在整个应用程序中始终从隔离存储中读取的文件(图像和文本文件)感到困惑。 当前处于测试/调试模式,运行模拟器时,我正在使用Windows Phone电动工具将这些文件添加到隔离存储中,这是我第一次运行该应用程序时, ...

3 WP8中的Json格式

我正在尝试在WP8中创建以下格式的json字符串 {“用户”:{“电子邮件”:“ abc@gmail.me”,“密码”:“ abc”}} 我已经创建了{ "email": "abc@gmail.me", "password": "abc*"}部分,例如 但是,如何将所有 ...

6 解析WP8中的不同Json对象

请帮助我解析此Json示例,因为由于它的复杂性以及其中的不同对象,我无法对其进行解析。 当相同对象和相同结构的列表不像下面的列表时,我能够解析Json。 任何帮助将不胜感激。 ...

8 从wp8中的scheduletaskagent调用asmx服务时出现stackoverflow异常

我有一个引用wp8类库的wp8项目。 类库具有服务参考。 我还有一个wp8任务代理项目,该项目引用类库来更新实时磁贴。 从电话项目中调用服务方法时,一切工作正常,但从任务代理中调用服务方法时,我开始收到堆栈溢出异常或内存不足异常。 该错误发生在GetDataAsync上。 但是, ...

10 HttpClient 中的 GetStringAsync 方法在 WP8 中引发异常

最近,我为 WP8 开发了一个应用程序,一开始一切正常。 但是,从昨天晚上开始,我在尝试从 url 检索RSS 数据时遇到错误。 这是我用来获取数据的代码的一部分: 其中 source 是包含获取RSS 数据的 url 的字符串。 正如评论的那样,一开始它工作正常,我能够使用它来处理数据。 ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2022 STACKOOM.COM