title: Rest Post call with Authentication Token
body: <p>I'm trying to send a Post request to SharePoint Online (Claims Based Auth Site) from my client application (WPF application). In this case it should be an update to a ListItem to change the 'Title' to 'Test'.</p>
  
  <p>I'm retrieving the CookieContainer via <a href="https://github.com/rmorg/SPFunnelback/blob/master/SharePoint%20Test%20Scripts/C%23/Wictor.Office365.ClaimsDemo/MsOnlineClaimsHelper.cs" rel="nofollow">MsOnlineClaimsHelper Class</a>
  which successfully returns me an auth token.</p>
  
  <p>But when i try to send the request the response is <code>The remote server returned an error: (403) Forbidden.</code></p>
  
  <p><strong>WebRequest Code</strong></p>
  
  <pre><code>try
  {
      var claimshelper = new MsOnlineClaimsHelper(baseUrl, _userName, _password);
      var request = (HttpWebRequest)WebRequest.Create(baseUrl + "/" + url);
  
      request.CookieContainer = claimshelper.CookieContainer;
      request.Method = "POST";
      request.Headers.Add("X-HTTP-Method", "MERGE");
      request.Headers.Add("If-Match", "*");
      request.Accept = "application/json;odata=verbose";
  
      using (var streamWriter = new StreamWriter(request.GetRequestStream()))
      {
          streamWriter.Write(json);
          streamWriter.Flush();
      }
  
      var webResp = request.GetResponse() as HttpWebResponse;
      var theData = new StreamReader(webResp.GetResponseStream(), true);
      string payload = theData.ReadToEnd();
  }
  catch (Exception ex)
  {
  
  
  }
  </code></pre>
  
  <p><strong>Rest Url:</strong></p>
  
  <p><code>/_api/lists/getbytitle('SampleList')/items(1)</code></p>
  
  <p><strong>Json Payload:</strong></p>
  
  <pre><code>string json = "{ '__metadata': { 'type': 'SP.Data.SampleListListItem' }, 'Title': 'Test'}";
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <p><code>The remote server returned an error: (403) Forbidden.</code></p>