Sending Parameters thro WEB get method in REST services
-
Monday, April 30, 2012 2:28 PM
Dear All,
I am trying to send parameters in the WEB -GET method but nothing seems to work. Please find the below sample which I am trying right now,
public interface IService { [OperationContract] [WebGet(UriTemplate = "User?username={username}&password={password}", BodyStyle = WebMessageBodyStyle.Wrapped)] Stream Signin(string username, string password);}On executing the above method, it just says, 405 Method not allowed.
I even tried with the Web-invoke with METHOD type as GET, It doesn't even work. For our scenario, we need to achieve this with GET only.
Please help.
Many thanks,
Balaji Palamadai
It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.
- Edited by Balaji Palamadai Monday, April 30, 2012 2:30 PM Updated error info
All Replies
-
Tuesday, May 01, 2012 1:35 AMModerator
Hello, make sure you're using webHttpBinding and you have the webHttp behavior. Something like:
<endpointBehaviors>
<behavior>
<webHttp/>
</behavior>
</endpointBehaviors>Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email. -
Tuesday, May 01, 2012 4:36 PM
Can you post your config file and also how you are hosting your service?
Try to perform a GET from Fiddler and the request should looks something like below:
GET http://localhost/SampleApp/Service1.svc/User?username=test&password=testpassword HTTP/1.1
Content-Type: application/xml
Host: localhostRajesh S V
-
Wednesday, May 02, 2012 8:21 AM
hii I have tried that already, it doesn't seem to work, I am pasting the config below which I tried,
<services>
<service behaviorConfiguration="omkar.HomeManagement.omkarServiceBehavior" name="omkar.HomeManagement.IomkarService">
<endpoint address="" binding="wsHttpBinding" contract="omkar.HomeManagement.IomkarService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="web" binding="webHttpBinding" contract="omkar.HomeManagement.IomkarService" >
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>@Rajesh S V :
We don't do any special hosting for our REST services, we just leave that to default. I haven't tried the GET from fiddler, will try and let you know.
Many thanks,
Balaji Palamadai
It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.
- Edited by Balaji Palamadai Wednesday, May 02, 2012 8:22 AM alignment
-
Wednesday, May 02, 2012 8:43 AM
In your config entry the service element has the name of the Interface "omkar.HomeManagement.IomkarService" whereas it should have the implemenatation class name. Once you change that should get it working.
NOTE: The value for the name attribute of the service element should be fully qualified.
Rajesh S V
-
Thursday, May 03, 2012 10:55 AM@Rajesh S V: Thanks for the reply, We tried that , still didn't work.
Many thanks, Balaji Palamadai It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.
-
Friday, May 04, 2012 2:21 AMModeratorI noticed you have used "web" as your relative address for the webHttpBinding endpoint. Make sure you're connecting to the correct address. For example: http://localhost/SampleApp/Service1.svc/web/...
Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email. -
Friday, May 04, 2012 8:26 AM
For the above config your Raw GET request would looks as below:
GET http://localhost/SampleApp/Service1.svc/web/User?username=test&password=testpassword HTTP/1.1
Content-Type: application/xml
Host: localhostAlso you would have changed the name attribute value in service element to the implementation class.
Rajesh S V

