title: RestSharp weird error on Method.Put
body: <p>I'm trying to update a resource using RestSharp. The API works well because are used in another application so this exclude some routing issues or whatever the problem is on my side not on API one.</p>
  
  <p>Anyways. My current scenario is that I want to update a specific resource located at <code>host/api/resource/id</code></p>
  
  <p>This is my current code inside the <code>DataProvider</code> layer</p>
  
  <pre><code>public override bool Update(string resource, Dictionary&lt;string, object&gt; properties)
  {
      this.request = new RestRequest(resource + "/{id}", Method.PUT);
  
      for (int i = 0; i &lt; properties.Count; ++i)
      {
          KeyValuePair&lt;string, object&gt; kvp = properties.ElementAt(i);
          if (kvp.Key != "id")
              this.request.AddParameter(kvp.Key, kvp.Value, ParameterType.GetOrPost);
          else
              this.request.AddParameter(kvp.Key, kvp.Value, ParameterType.UrlSegment);
      }
  
      var response = this.CallApi();
      // ... other stuff
  }
  </code></pre>
  
  <p>This code simply create the request and the correct parameters based on the dictionary that the method received from outside, then it calls the <code>CallApi()</code> method which is this</p>
  
  <pre><code>private IRestResponse CallApi()
  {
      var client = new RestClient(BaseUrl);
      var response = client.Execute(this.request);
  
      if(response.ErrorException != null)
      {
          // Response has some error!
          // ... other stuff
      }
  
      if(response.StatusCode != System.Net.HttpStatusCode.OK)
      {
          // Response received something different from HTTP status code OK
          // ... other stuff
      }
  
      return response;
  }
  </code></pre>
  
  <p>CallApi works perfectly for every other call such as GET, POST, DELETE and even PATCH but when I try to use it with Update, and thus using PUT, the response received from <code>client.Execute(this.request)</code> is 405 Method Not Allowed.</p>
  
  <p>After debugging a little bit I figured it out that the respone has a <code>ResponseUri</code> with only the <code>host</code> string instead of <code>host/api/resource/id</code> this seems to be caused by the</p>
  
  <p><code>this.request = new RestRequest(resource + "/{id}", Method.PUT);</code></p>
  
  <p>in fact if I remove the <code>/{id}</code> part, the RequestUri has the correct form of <code>host/api/resource</code>, of course without the id, which is wrong anyway because I need the id :-/ </p>
  
  <p>Does anyone know why this is happening?</p>