メッセージ要素を持つ Json オブジェクトを受け取るエンドポイントがあり、残りは異なるプロパティを持つことができます。次に例を示します。
public void SendMessage(IDictionary<string, string> message)
{
var client = new RestClient(MahUrl);
var request = new RestRequest(Method.POST);
var json = new JObject();
foreach (var pair in message)
{
json.Add(pair.Key, pair.Value);
}
json = new JObject(new JProperty("message", json));
// {
// "message":
// {
// "prop1": "val1",
// "foo": "bar",
// "batman": "robin"
// }
// }
// not quite sure here
request.?
// send request
}
.Net オブジェクトをシリアル化/逆シリアル化する方法の例をたくさん見てきましたが、ご覧のとおり、json オブジェクトのプロパティは何でもかまいません。RestSharp を使用して生の json を投稿するにはどうすればよいですか?