title: REST api with C#.NET complex json data in body posting
body: <p>I want to use sms gateway in my app. that's why I've contact with an operator and the operator give me a api format.</p>
  
  <p>URL: <a href="https://ideabiz.lk/apicall/smsmessaging/v2/outbound/3313/requests" rel="nofollow">https://ideabiz.lk/apicall/smsmessaging/v2/outbound/3313/requests</a></p>
  
  <p>Request header</p>
  
  <pre><code>Content-Type: application/json 
  Authorization: Bearer [access token] 
  Accept: application/json
  </code></pre>
  
  <p>Body</p>
  
  <pre><code>{
      "outboundSMSMessageRequest": {
          "address": [
              "tel:+94771234567"
          ],
          "senderAddress": "tel:12345678",
          "outboundSMSTextMessage": {
              "message": "Test Message"
          },
          "clientCorrelator": "123456",
          "receiptRequest": {
              "notifyURL": "http://128.199.174.220:1080/sms/report",
              "callbackData": "some-data-useful-to-the-requester"
          },
          "senderName": "ACME Inc."
      }
  }
  </code></pre>
  
  <hr>
  
  <p>Now, I've code it :</p>
  
  <pre><code>RestClient client = new RestClient(@"https://ideabiz.lk/");
  RestRequest req = new RestRequest(@"apicall/smsmessaging/v2/outbound/3313/requests", Method.POST);
  
  req.AddHeader("Content-Type", @"application/json");
  req.AddHeader("Authorization", @"Bearer " + accessToken.ToString());
  req.AddHeader("Accept", @"application/json");
  
  string jSon_Data = @"{'outboundSMSMessageRequest': {'address': ['tel:+94768769027'],'senderAddress': 'tel:3313','outboundSMSTextMessage': {'message': 'Test Message : " + System.DateTime.Now.ToString() + "'},'clientCorrelator': '123456','receiptRequest': {'notifyURL': 'http://128.199.174.220:1080/sms/report','callbackData': 'some-data-useful-to-the-requester'},'senderName': ''}}";
  
  
  JObject json = JObject.Parse(jSon_Data);
  req.AddBody(json);
  
  IRestResponse response = client.Execute(req);
  string x = response.Content.ToString();
  Console.WriteLine(x.ToString());
  </code></pre>
  
  <hr>
  
  <p>When i execute this program, in the line</p>
  
  <p>req.AddBody(json);</p>
  
  <p>my system crash and give error message that:</p>
  
  <p>An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll</p>
  
  <p>How can i post complex JSON by using C#.NET ?</p>