4

I have a REST WCF service. When a POST attempt is made to this service to an operation as mentioned below, I get the below error:

[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "", RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
void Write();

Error: HTTP 307 There is no operation listening for https://xx.xxx.xx.xxx/EnrollmentServer/Discovery.svc, but there is an operation listening for https://xx.xxx.xx.xxx/EnrollmentServer/Discovery.svc/, so you are being redirected there.

Any pointers will be appreciated.

Thomas
  • 1,970
  • 4
  • 28
  • 59

1 Answers1

9

Change your UriTemplate to "/" instead. RESTful WCF has a "thing" about wanting Uris ending with / instead of no ending.

Also, use the Uri with the ending slash to avoid WCF responding with the 307.

Jeff Fischer
  • 2,063
  • 1
  • 17
  • 12
  • 2
    Although it is old thread, I have been struggling for Android POST to WCF RESTful web service and didn't know this "Slash" thing can cause such difference. I have spent almost 3 weeks to find the root cause on my android source until I found this post and notice actually it is my WCF causing the problem. (I tested with Fiddler and it redirected to 307 and then correct result so I thought it is not my WCF issue until I see this post). Thanks for the pointer. – scsfdev Sep 21 '18 at 03:12