0

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);
4

1 回答 1

0

Found the solution myself. Instead of attaching a Json as body, I need to set the values to the dictionary like

dict.Add("name", "John"); dict.Add("city", "New York");

and use the dict as second parameter of InsertEntryAsync("PeopleSet", dict).

于 2018-11-16T21:37:19.287 回答