要使用Simple.OData.Client创建条目,我需要使用InsertEntryAsync()方法。对,是这样?
oData请求的主体包含Json格式的插入数据,但是我必须在哪里设置这种调用的主体?
我的代码看起来像这样:
using Simple.OData.Client;
var client = new ODataClient(
new ODataClientSettings
{
BaseUri = baseUri,
Credentials = credentials,
OnTrace = OnTraceHandler,
});
var headers = new Dictionary<string, IEnumerable<string>>
{
{ "Accept-Language", new string[] { "de-DE" } },
{ "Accept", new string[] { "application/json" } },
{ "X-CSRF-TOKEN", new string[] { Class1.x_scrf_token } }
};
client.UpdateRequestHeaders(headers);
var dict = new Dictionary<string, object>();
string body = "{\"name\":\"John\", \"city\":\"New York\"}";
var entryInsert = await client.InsertEntryAsync("PeopleSet", dict);发布于 2018-11-17 05:37:19
我自己找到了解决方案。我需要将值设置为字典,而不是将Json作为主体附加
Dict.Add(“姓名”,“约翰”);dict.Add(“城市”,“纽约”);
并使用dict作为InsertEntryAsync("PeopleSet",dict)的第二个参数。
https://stackoverflow.com/questions/53226784
复制相似问题