c# API "Unexpected character encountered while parsing value: S. Path '', line 0, position 0"
<p>I use multiple API coded in c# that works well. I want to use one receiving an anonymous object (I don't want to create a Class). I have a problem when I try to deserialize the object. </p>

<p>I have an API following this scheme, it works well when it's called from <code>python</code> using the <code>json_dumps</code> function. But when I try with <code>JSON.stringify</code> (from an a or even POSTMAN, I have a 400 bad request.</p>

<p>Here is my code, I have tried a lot of things :</p>

<pre><code>[WebInvoke(Method = "POST", UriTemplate = "myUrl")]
[OperationContract]
public Message myMethod(object objectSentByUser)
{

    var perso = JsonConvert.DeserializeObject&lt;dynamic&gt;(objectSentByUser.ToString());
</code></pre>

<p><code>JsonConvert.DeserializeObject&lt;dynamic&gt;</code> waits for a string, I tried:</p>

<p>-to specify <code>objectSentByUser</code> as a string in the argument of <code>myMethod</code>
When I do so, I've got a 400 without even entering the method (I tried to send a JSON, to add quotes, to send a string etc...)</p>

<p>-to cast with <code>(string)objectSentByUser</code>, it doesn't work</p>

<p>-to use the <code>toString()</code> method, which leads to the next error:
    Unexpected character encountered while parsing value: S. Path '', line 0, position 0
which is quite normal because <code>objectSentByUser.toString()</code> returns "System.Object"
(but why does it work when used with python json_dump?)</p>

<p>This code works when called with python function json_dump that returns an object like this:</p>

<p>"{\\"key1\\":\\"value1\\",...}"</p>

<p>From Postman I send a classic POST with <code>application/json</code> as <code>contentType</code> and a valid <code>JSON</code> in the body (verified on a website found in an another discussion on stackoverflow)</p>

<p>Thanks a lot for your help</p>

<p>See you</p>