title: Insert values in mySQL using wcf REST and Android
body: <p>I wrote a REST web service in C#. Get request works fine, but insert, update and delete not.
  When I try to insert some values from an Android tablet (client) via the REST service into a mySQL database an error occurs:  Method not allowed</p>
  
  <p>I send a JSON string from the android client to the web service:</p>
  
  <p>in Android Developer Tool (eclipse):</p>
  
  <pre><code>String url = IP + PORT +"/RESTService/insert/";
              HttpClient client = new DefaultHttpClient();
              HttpResponse response;
              JSONObject json = new JSONObject();
  
                  HttpPost post = new HttpPost(url);
                  json.put("userName", name);
                  json.put("userPassword", password);
  
                  StringEntity se = new StringEntity(json.toString());
                  se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,"application/json"));
                  post.setEntity(se);
                  response = client.execute(post);
  </code></pre>
  
  <p>in C#:
  Service interface:</p>
  
  <pre><code>[OperationContract]
      [WebInvoke(Method = "POST", UriTemplate = "/insert/{jsonObj}", 
          RequestFormat = WebMessageFormat.Json,       
          ResponseFormat = WebMessageFormat.Json,
          BodyStyle = WebMessageBodyStyle.Bare)]
      void InsertUser(string jsonObj);
  </code></pre>
  
  <p>Service methode:</p>
  
  <pre><code> public void InsertUser(string jsonObj)
      {
          string name = null;
          string password = null;
          DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(User));
          dynamic dynObj = JsonConvert.DeserializeObject(jsonObj);
  
          foreach (var data in dynObj.userObject)
          {
              name = data.userName;
              password = data.userPassword;
          }
  
         string sql = "INSERT INTO user (userName, userPassword) VALUES('" + name + "', '" + password +"';)";
  
         if (conn.State == ConnectionState.Closed)
         {
             conn.Open();
         }
  
         command = new MySqlCommand(sql, conn);
         command.ExecuteNonQuery();
         conn.Close();
         command.Dispose();
      }
  </code></pre>
  
  <p>My User:</p>
  
  <pre><code>    namespace RESTService
  {
      [DataContract]
      public class User
      {
          [DataMember]
          public string userName { get; set; }
          [DataMember]
          public string userPassword { get; set; }
  
          public User(string name, string password)
          {
              this.userName = name;
              this.userPassword = password;
          }
      }
  </code></pre>
  
  <p>When I start the web service and try to insert the values via android app, nothing happens. I think, that the values from the app don't reach the web service. But I have no idea why.
  It would be great, if somebody can help me :). </p>
  
  <p>Thanks in advance</p>