title: Retrofit Android add new row in MySQL
body: <p>I am using <strong>Retrofit</strong> library in my project, to add a row in <strong>MySQL</strong> DB, and I have some problems with <strong>@POST method</strong>.</p>
  
  <p>This is my PHP code in file <strong>test_retro_post.php</strong> on server with POST method:</p>
  
  <pre><code>&lt;?php
  $response = array();
  if (isset($_POST['id']) &amp;&amp; isset($_POST['name']) &amp;&amp; isset($_POST['price'])) {
  
  $id = $_POST['id'];
  $name = $_POST['name'];
  $price = $_POST['price'];
  
  // include db connect class
  require_once __DIR__ . '/db_connect.php';
  
  // connecting to db
  $db = new DB_CONNECT();
  
  // mysql inserting a new row
  $result = mysql_query("INSERT INTO test_retro(id, name, price) VALUES('$id', '$name', '$price')");
  
  
  if ($result) {
      // successfully inserted into database
      $response["success"] = 1;
      $response["message"] = "Product successfully created.";
  
      // echoing JSON response
      echo json_encode($response);
  } else {
      // failed to insert row
      $response["success"] = 0;
      $response["message"] = "Oops! An error occurred.";
  
  
      echo json_encode($response);
  }
  } else {
  
  $response["success"] = 0;
  $response["message"] = "Required field(s) is missing";
  echo json_encode($response);
  }
  ?&gt;
  </code></pre>
  
  <p>Sending usual HttpRequest with custom JSONparser, everything is working:</p>
  
  <pre><code>        List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
          params.add(new BasicNameValuePair("id", id));
          params.add(new BasicNameValuePair("name", name));
          params.add(new BasicNameValuePair("price", price));
  
          // getting JSON Object
          // url_create_product is URL to my PHP file with POST method
  
  
          JSONObject json = jsonParser.makeHttpRequest(url_create_product,
                  "POST", params);
  </code></pre>
  
  <p>But something wrong when using Retrofit. The new row is not added. 
  This is interface <strong>Api_post.java</strong> with <strong>Retrofit`s @POST method</strong>:</p>
  
  <pre><code> public interface Api_post{
      @POST("/test_retro/test_retro_post.php")
     Call&lt;RequestBody&gt; createProd(@Body RequestBody body);
  </code></pre>
  
  <p>My RequestBody class (RequestBody.java):</p>
  
  <pre><code>public class RequestBody{
    int id;
    String name;
    int price;
  
  RequestBody(int id, String name, int price){
      this.id=id;
      this.name = name;
      this.price = price;
  }
  
  public int getPrice() {
      return price;
  }
  
  public void setPrice(int price) {
      this.price = price;
  }
  
  public int getId() {
      return id;
  }
  
  public void setId(int id) {
      this.id = id;
  }
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  }
  </code></pre>
  
  <p>And finally calling Retrofit in activity:</p>
  
  <pre><code> Retrofit restAdapter = new Retrofit.Builder()
              .baseUrl(Url.BASE_URL)
              .addConverterFactory(GsonConverterFactory.create())
              .build(); 
    Api_post api_post = restAdapter.create(Api_post.java);
    Call&lt;RequestBody&gt; call = api_post.createProd(new RequestBody(3, "prod_3", 300);
  </code></pre>
  
  <p>And then execute this call in AsyncTask:</p>
  
  <pre><code>call.execute();     
  </code></pre>
  
  <p>The new row in MySQL DB isn`t added. Please tell me what is wrong with this code? Maybe i need custom converter?</p>