Click here to Skip to main content
15,891,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am Creating Android App has a Http request as following:

.Call API http://MY API/GetMessage

.take parameter id as JSON string Post request

.Go to another Activity to show the return message

.hint URL like that http://MY API/GetMessage?id= {%22Id%22:%221%22,%22UserName%22:%John%22}

I wrote my code to get the message from the request response but the response is 404 Page not found and i don't know the reason,this is my code :

What I have tried:

Java
HttpPost httpPost = new HttpPost(url);
            HttpClient httpClient = new DefaultHttpClient();

            try {

                JSONObject json = new JSONObject();
                json.put("Id", 1);
                json.put("UserName", "userName");
                StringEntity se = new StringEntity( json.toString());
                httpPost.setEntity(se);
                HttpResponse response = httpClient.execute(httpPost);
                String result = EntityUtils.toString(response.getEntity());
                return result;
Posted
Comments
Richard MacCutchan 20-Apr-16 11:43am    
It is nothing to do with your code, it is the server's response telling you that the requested page does not exist.
Asmaa Rashad 21-Apr-16 3:55am    
yes the response tell me the requested page not found

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900