title: How to close CRM opportunity entity using C# web api
body: <p>I am new to CRM. I had implemented OAuth for application. I am using web api approach to access specific CRM user data. I had implemented web api successfully for "Get User Opportunities", "Update User Opportunity". But i am unable to do same for "close opportunity" or "win opportunity". </p>
  
  <p>Note: I am not using OrganizationService proxy while accessing user data. I am using OAuth token and  calling specific API request URL.</p>
  
  <p>Please guide me to achieve same. Highly appreciable if anyone can show any samples on code and or how to test same in postman.</p>
  
  <p>My queries:</p>
  
  <p>1) Is it possible using OAuth token,can we connect to OrganizationServiceProxy without passing user credentials?</p>
  
  <p>Ex: Get Opportunities</p>
  
  <p>Request URL : <a href="https://testdevcrm.crm8.dynamics.com/api/data/v9.1/opportunities" rel="nofollow noreferrer">https://testdevcrm.crm8.dynamics.com/api/data/v9.1/opportunities</a></p>
  
  <p>Header:</p>
  
  <p>Authorization:Bearer (accessToken)</p>
  
  <p>Accept:application/json</p>
  
  <p>OData-MaxVersion:4.0</p>
  
  <p>OData-Version:4.0</p>
  
  <p>Method Type : GET</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>  #region FectchUserOpportunities
      public async Task&lt;JToken&gt; FectchUserOpportunities(string systemuserid,string bearerToken)
      {
          JToken jResu = null;
          try
          {
              var httpClient = new HttpClient();
  
              httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken);
              ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
              string filter = "&amp;$filter=_createdby_value eq '" + systemuserid + "' and opportunityid ne null and statuscode eq 1&amp;$orderby=createdon asc&amp;$top=5";
              string opportunitiesURL = string.Concat(GenericMethods.GetAppSetting("FetchCRMOpportunitiesAPI"), filter);
              var result = httpClient.GetAsync(opportunitiesURL).Result;
  
              if (result != null)
              {
                  var opporJSON = await result.Content.ReadAsStringAsync();
                  JToken jsonResult = JsonConvert.DeserializeObject&lt;JObject&gt;(opporJSON);
                  jResu = jsonResult["value"];
              }
              else
              {
                  jResu = null;
              }
          }
          catch (Exception ex)
          {
          }
          return jResu;
      }
  
      #endregion
  </code></pre>