Discussion:
[chromium-discuss] getting "method not allowed" 405 when trying to consume RESTful with javascript (in chrome)
Liron Ladelsky
2018-07-11 16:03:13 UTC
Permalink
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "/Address/{address_id}")]
bool IsOrderConnected(string address_id);



javascript :

function call_REST_address(address_recordid) {
//var configuratioName = "IsAddressConnectedToOrdersWS"
//var request = "el_configurations?$filter=el_name eq '" +
configuratioName + "'&$select=el_value";
var request = "http://crm_dev:82/crm15.svc/address/" + address_recordid;
//var parameters = { 'address_id': address_recordid };
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", request, true);
xmlhttp.setRequestHeader("Content-Type", "application/json;
charset=utf-8");
xmlhttp.setRequestHeader("Accept", "application/json");
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 /* complete */) {
//xmlhttp.onreadystatechange = null; //avoids memory leaks
if (xmlhttp.status == 201 || xmlhttp.status == 200) {
var is_connect =
xmlhttp.responseXML.documentElement.childNodes[0].data;
if (JSON.parse(is_connect)) {

Xrm.Page.getAttribute("el_order_connect").setValue(JSON.parse(is_connect));
}
}
else {
//Failure
alert("Wrong xmlhttp Status!");
}
}
}
xmlhttp.send();
}
--
--
Chromium Discussion mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discuss+***@chromium.org.
PhistucK
2018-07-12 15:46:16 UTC
Permalink
Does it work in other browsers?
If so, what do you see in the Network panel of the Developer Tools? Is it
really GET?
What do you see in a network sniffer like Fiddler? Is it really GET? And
when other browser try, is it really GET?
Any other differences?

If it does not work in other browsers, you most likely have a server side
issue.

☆*PhistucK*
Post by Liron Ladelsky
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "/Address/{address_id}")]
bool IsOrderConnected(string address_id);
function call_REST_address(address_recordid) {
//var configuratioName = "IsAddressConnectedToOrdersWS"
//var request = "el_configurations?$filter=el_name eq '" +
configuratioName + "'&$select=el_value";
var request = "http://crm_dev:82/crm15.svc/address/" +
address_recordid;
//var parameters = { 'address_id': address_recordid };
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", request, true);
xmlhttp.setRequestHeader("Content-Type", "application/json;
charset=utf-8");
xmlhttp.setRequestHeader("Accept", "application/json");
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 /* complete */) {
//xmlhttp.onreadystatechange = null; //avoids memory leaks
if (xmlhttp.status == 201 || xmlhttp.status == 200) {
var is_connect =
xmlhttp.responseXML.documentElement.childNodes[0].data;
if (JSON.parse(is_connect)) {
Xrm.Page.getAttribute("el_order_connect").setValue(JSON.parse(is_connect));
}
}
else {
//Failure
alert("Wrong xmlhttp Status!");
}
}
}
xmlhttp.send();
}
--
--
http://groups.google.com/a/chromium.org/group/chromium-discuss
---
You received this message because you are subscribed to the Google Groups
"Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
--
Chromium Discussion mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discuss+***@chromium.org.
Loading...