Hello,
Can anybody help me to integrate the crm data to the external html page,i tried to integrate the crm data by using web api but not able to retrieve the data , below is my code please anybody suggest me to complete it.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Login Form</title>
</head>
<body>
<table>
<tr>
<td>
<label style="margin-left: 33px;">URL :</label>
<input type="url" name="URL" placeholder="Enter your URL" id="URL" required>
</td>
</tr>
<tr>
<td>
<label>Username :</label>
<input type="text" name="username" placeholder="Enter your user name" id="username" required>
</td>
</tr>
<tr>
<td>
<label>Password :</label>
<input type="password" name="username" placeholder="Enter your Password" id="password" style="margin-left: 3px;" required>
</td>
</tr>
<tr>
<td>
<label style="font-size: 12px;">Account:</label>
<input name="accountfield" placeholder="Enter your Account field" id="accountfield" style="margin-left: 1px;" required>
</td>
</tr>
<tr>
<td>
<button style="margin-left: 93px;margin-top: 2px;" id="btn">Submit</button>
<button>Cancel</button>
</td>
</tr>
</table>
</body>
<script>
var btn= document.getElementById("btn");
btn.addEventListener('click',function(){
var accountfield= document.getElementById("accountfield").value;
var password= document.getElementById("password").value;
var username = document.getElementById("username").value;
var URL = document.getElementById("URL").value;
var req = new XMLHttpRequest();
req.open("GET", "URL" + "/api/data/v9.1/accounts?$select=name", 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() {
debugger;
if (this.readyState == 4) {
req.onreadystatechange = null;
if (this.status == 200) {
var result = JSON.parse(this.responseText);
var results = result.value;
if(results.length >= 1)
{
}
}
}
};
req.send();
})
</script>
</html>

Report
All responses (
Answers (