1

Using RestSharp 105.2.3

The API I am talking to requires use to send in a json body, but with a @c symbol as part of the field name. This is illegal in C# of course so I can't just use a dynamic object like below.

Is there a way to get the "@c" in the field name?

        var client = new RestClient("https://aaa.bbb.com");
        var request = new RestRequest(Method.POST);
        request.AddJsonBody(new
        {
            @c=".Something",
            username="johnsmith"
        });
Ian Vink
  • 66,960
  • 104
  • 341
  • 555

1 Answers1

0

You could just use a string like this:

var client = new RestClient("https://aaa.bbb.com");
var request = new RestRequest(Method.POST);

string json = "{\"@c\":\".Something\", \"username\":\"johnsmith}";
request.AddJsonBody(json);
johannespartin
  • 501
  • 3
  • 15