title: How to POST And GET with the same Request Using Android Studio And Web Api
body: <p>I'm developing an Android App Using Android Studio
  And Back-end Using Asp.Net Web API.</p>
  
  <p><strong>Web Api Side</strong></p>
  
  <pre><code>[System.Web.Http.AcceptVerbs("GET", "POST")]
  [System.Web.Http.HttpGet]
  public dynamic GetTest(string name)
  {
      List&lt;person&gt; persons = new List&lt;person&gt;()
      {
         new person { ID = 1, Name = "Loai" },
         new person { ID = 2, Name = "rami" },
         new person { ID = 3, Name = "Omar" },
         new person { ID = 4, Name = name}
       };
      IEnumerable&lt;person&gt; p = persons.ToList();
      return new { Students = p };
  }
  </code></pre>
  
  <p>On This Link </p>
  
  <p><a href="http://qjtest.azurewebsites.net/api/test" rel="nofollow">http://qjtest.azurewebsites.net/api/test</a></p>
  
  <p>if you want to set the <strong>name</strong> parameter value you may use</p>
  
  <p><a href="http://qjtest.azurewebsites.net/api/test?name=ayman" rel="nofollow">http://qjtest.azurewebsites.net/api/test?name=ayman</a></p>
  
  <p><strong>Android Studio Side</strong></p>
  
  <p>I've used this code </p>
  
  <pre><code>  final String URL = "http://qjtest.azurewebsites.net/api/test";
              HashMap&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
              params.put("name", "ayman");
              JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, URL, new JSONObject(params),
                      new Response.Listener&lt;JSONObject&gt;() {
                          @Override
                          public void onResponse(JSONObject response) {
                              try {
                                  JSONArray jsonArray = response.getJSONArray("Students");
                                  for (int i = 0; i &lt; jsonArray.length(); i++) {
                                      JSONObject student = jsonArray.getJSONObject(i);
                                      String ID = student.getString("ID");
                                      String Name = student.getString("Name");
                                      textview.append(ID + " - " + Name + "\n");
                                  }
                              } catch (JSONException e) {
                                  e.printStackTrace();
                              }
                          }
                      }, new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
                      VolleyLog.e("Error: ", error.getMessage());
                  }
              });
              requestQueue.add(req);
  </code></pre>
  
  <p>when i run the application and press the button this is the error shows in logcat</p>
  
  <blockquote>
  <pre><code>11-17 15:08:48.035 9628-9654/com.sqlite_test.alhalabi.loai.test_gson E/Volley: [155]
  </code></pre>
    
    <p>BasicNetwork.performRequest: Unexpected response code 404 for
    <a href="http://qjtest.azurewebsites.net/api/test" rel="nofollow">http://qjtest.azurewebsites.net/api/test</a>
        11-17 15:08:48.041 9628-9628/com.sqlite_test.alhalabi.loai.test_gson E/Volley: <a href="http://qjtest.azurewebsites.net/api/test" rel="nofollow">1</a>
    2.onErrorResponse: Error:</p>
  </blockquote>