EC5 API
Testing EC5 API
by ParanoidAndroid77
HTML
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
JavaScript
var params = {
grant_type: 'client_credentials',
client_id: 2,
client_secret: 'QowjYIFrWbzLEwttXzuTnb20OPbRWwlPlaNLQ6VW'
}
$.ajax({
url: 'https://test.epicollect.net/api/oauth/token',
type: 'POST',
contentType: 'application/vnd.api+json',
data: JSON.stringify(params),
success: function(response) {
console.log(JSON.stringify(response));
//the token is valid for 2 hours
_getEntries(response.access_token);
},
error: function(xhr, status, error) {
console.log(xhr.responseText);
}
});
function _getEntries(token) {
$.ajax({
url: 'https://test.epicollect.net/api/export/entries/ec5-api-test',
type: 'GET',
contentType: 'application/vnd.api+json',
headers: {
Authorization: 'Bearer ' + token
},
success: function(response) {
console.log(JSON.stringify(response));
},
error: function(xhr, status, error) {
console.log(xhr.responseText);
}
});
}