c# - NullReferenceException after AddJsonBody -


[restsharp 105.2.3]

using addjsonbody, end request carrying parameters object 1 item reading

[1] = {={"id":"100007988",[...]}} 

executing request, nullreferenceexception thrown.

if use

request.addparameter("application/json", contentjson, parametertype.requestbody); 

instead, parameters item reads this

[1] = {application/json={"id":"100007988",[...]}} 

executing request succeeds.

unfortunately, latter variant requires me serialize json object explicitly while other uses iserializer has been declared handler "application/json".

do miss or (pretty basic) bug in restsharp?

having sources, found missing set contenttype property in iserialize implementation. used set name of parameter.

so, added constructor iserialize implementation stating

this.contenttype = "application/json"; 

did trick.


Comments