jQuery & WCF Data Service - PUT Update - Rejected with 405 Method Not Allowed
-
Sunday, September 12, 2010 8:45 PM
I am writing a sample jQuery/WCF Data Service app to utilize OData, however I am getting a status code 405 - Method not allowed when I attempt to update an entity with a PUT Http method.
I have configured my WCF Data Service as follows:
public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("jCredentials_PINs", EntitySetRights.All); config.SetEntitySetAccessRule("jCredentials_PINTree", EntitySetRights.All); //config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; }
I am attempting to update the jCredentials_PINs table.My jQuery call to update the WCF Data Service is as follows:
function UpdatePIN(selectedTreeNode, updateObj) { var url = dataService + "/jCredentials_PINs(guid'" + selectedTreeNode.get_value() + "')"; var json = JSON.stringify(updateObj); $.ajax({ url: url, data: json, type: "PUT", contentType: "application/json; charset=utf-8", timeout: 10000, dataType: "json", success: AjaxPINUpdateSuccess, error: AjaxPINUpdateFailure }); } function AjaxPINUpdateSuccess(result) { alert(result); }; function AjaxPINUpdateFailure(result) { alert("PIN Update Failure - Status Code=" + result.status + ", Status=" + result.statusText); return; };
I am using Windows 7 / IIS 7.5. GETs against the jCredentials_PINs table work fine.
The only web.config configuration information is as follows:
<system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> </system.serviceModel>
Where else may there be configuration info which is preventing me from issuing a PUT method ?
Thanks for your help
Answers
-
Tuesday, September 21, 2010 5:27 PMModerator
Hi Raevean,
You will need to enable the PUT verb for the .svc extension in IIS 7.5 for any requests with the PUT verb to work .
Here's some documentation on how to do this : http://forums.iis.net/p/1153779/1887592.aspx
Phani Raj Astoria http://blogs.msdn.com/PhaniRaj- Marked As Answer by Pratik Patel - MSFTModerator Wednesday, September 22, 2010 4:43 PM
-
Thursday, September 23, 2010 9:36 PM
Sorry...you are all wrong.
The problem had to do with a WebDAV conflict....once I uninstalled WebDAV....the PUT verbs are working fine.....this is quite a puzzle....but glad to have it now working.
- Marked As Answer by Michael Sun [MSFT]Microsoft Employee, Moderator Monday, September 27, 2010 1:20 AM
All Replies
-
Sunday, September 12, 2010 9:54 PM
I do not try this using ajax but i was thinking that by using PUT verb you try to add an entity (or update i dont remember) to an entity set.... so why in the query string you pass in guid that should be in the object?
I would use this url instead no?
var url = dataService + "/jCredentials_PINs";
That could explain that the PUT method is not allowed... you try to call it against a specific entity url not the entityset
-
Thursday, September 16, 2010 8:12 AMModerator
Hi,
Raevean:
PUT - update existing entity (the URL needs to point to an entity instance)
POST - add a new entity (the URL needs to point to an entity set)As for the above question, I don't see anything particularly wrong with it. Could you please try to grab netwrok trace of the request/response with something like fiddler and post it here? (The 405 response should contain body with some error message).
Thanks,
Vitek Karas [MSFT]- Proposed As Answer by Michael Sun [MSFT]Microsoft Employee, Moderator Monday, September 20, 2010 1:15 AM
-
Tuesday, September 21, 2010 3:04 AMModerator
Hi,
I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions?
If you need further assistance, please feel free to let me know. I will be more than happy to be of assistance.
Have a nice day!
Best Regards,
Lingzhi SunMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. -
Tuesday, September 21, 2010 5:27 PMModerator
Hi Raevean,
You will need to enable the PUT verb for the .svc extension in IIS 7.5 for any requests with the PUT verb to work .
Here's some documentation on how to do this : http://forums.iis.net/p/1153779/1887592.aspx
Phani Raj Astoria http://blogs.msdn.com/PhaniRaj- Marked As Answer by Pratik Patel - MSFTModerator Wednesday, September 22, 2010 4:43 PM
-
Thursday, September 23, 2010 9:36 PM
Sorry...you are all wrong.
The problem had to do with a WebDAV conflict....once I uninstalled WebDAV....the PUT verbs are working fine.....this is quite a puzzle....but glad to have it now working.
- Marked As Answer by Michael Sun [MSFT]Microsoft Employee, Moderator Monday, September 27, 2010 1:20 AM