gpt4 book ai didi

c# - 使用 InvokeApiAsync () 传递参数时出现 System.ArgumentException

转载 作者:太空宇宙 更新时间:2023-11-03 12:52:16 25 4
gpt4 key购买 nike

尝试使用列表引用和对象作为参数发送,将一些参数传递给在 azure 移动服务上运行的自定义 API。然后我遇到此错误。

Could not determine JSON object type for type App7.DataModels.FriendCircle.

FriendCircle friendcircle = new FriendCircle();
List<Invitee> inviteelist;
try
{

Object[] ob = new Object[2] { friendcircle, inviteelist };
await App.azure_rendezvous_mobile_service_3Client.InvokeApiAsync("saveinvite", new JObject(new JProperty("params", ob)));

}
catch (MobileServiceInvalidOperationException ex)
{
System.Diagnostics.Debug.WriteLine("Exception is :" + ex.Message);

}

最佳答案

我尝试并能够向 azure 自定义 api 发送请求。!!将我的列表引用和对象 friend 圈序列化为 Json 并将其挂接到 Json 属性。

var jsoninviteelist= JsonConvert.SerializeObject(inviteelist);
var jsonfriendcircle = JsonConvert.SerializeObject(friendcircle);
await App.azure_rendezvous_mobile_service_3Client.InvokeApiAsync("saveinvite",new JObject(new JProperty("jsoninviteelist",jsoninviteelist),new JProperty("jsonfriendcircle", jsonfriendcircle)));

P.S 安装软件包>> NuGet 管理器中的 Newtonsoft.Json 并将其用作引用。

关于c# - 使用 InvokeApiAsync () 传递参数时出现 System.ArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35123535/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com