Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Web API returning 400 Bad Request

$
0
0

Hi All,

I am using Microsoft Dynamics 2016 Online.

I am have a HTML in which I have a javascript which calls a CRM WEB API and filters w.r.t fullname. Here is my code

var searchBoxSelectedValue = window.parent.Xrm.Page.getAttribute("new_name").getValue();

var req = new XMLHttpRequest();

req.open("GET", window.parent.Xrm.Page.context.getClientUrl() + "/api/data/v9.0/contacts?$select=fullname&$filter=fullname eq" + searchBoxSelectedValue, false);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var results = JSON.parse(this.response);

for (var i = 0; i < results.value.length; i++) {
var mydata = results.value[i]["fullname"];
}
} else {
alert(this.statusText);
}
}
};

req.send(); // error shown in this line

I am getting an error saying "Bad Request" 400. 

req.onreadystatechange = function() {} does not get executed, it gets skipped.

thanks in advance.

Regards,

Rahul


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images