I have the following code that should insert two fields into a database via a WCF Service but I get a 405 Method Not Allowed error when I test in Eclipse.
The WCF works from both Fiddler and my testing C# web client, I only get the error from Android via my phone, leading me to believe the problem may be in this code!
HttpPost request = new HttpPost("http://www.mysite.com/myservice.svc/postname?fname=fred&lname=frognoggle");
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(request);
Log.d("WebInvoke", "Saving : " + response.getStatusLine().getStatusCode());
Can anyone see what I’m missing!
Edit
I’m doing a post in Fiddler and if I post:
http://www.mysite.com/myservice.svc/postname?fname=fred&lname=frognoggle
It all works fine works.
Cheers,
Mike.
Update: back by request. The code below is what I am using to make a JSON POST on Android and it is working for me.
You are doing an HTTP POST in your Android code. Are you doing a POST in fiddler too or are you doing a GET? The reason I ask is that you are not sending a body with your post, only setting the query string. I have included my Android code that does a JSON POST to a WCF service.
Hope this helps…
If you post more information I will be glad to help and update answer.