Send a POST to url: http://api.heimdaldata.dk/badge/
With following POST dataset:
header: "#hashtag",
image: "image-blob",
title: "Queen",
name: "Daenerys Targaryen",
assignment: "Crew",
access: "All areas",
textColor: "#000000", // optional, default #000000
backgroundColor: "#FFFFFF", // optional, default #FFFFFF
Example JSON response:
{
"status": true,
"reason": "Job finished for badge-daenerys-targaryen",
"pdf": "http://api.heimdaldata.dk/badge/storage/pdf/badge-daenerys-targaryen.pdf?_=ha7YEi7wCChLXpbi0wcClPK52AWXMU22"
}
Javascript jQuery example code.
AJAX request & response:
$.ajax({
type: 'POST',
url: 'http://api.heimdaldata.dk/badge/',
dataType: "json",
data: {
header: "#hashtag",
image: "image-blob",
title: "Queen",
name: "Daenerys Targaryen",
assignment: "Crew",
access: "All areas",
},
async: true,
cache: false,
error: function(jqXHR, textStatus, errorThrown){
// Parse error output here
console.log(jqXHR, textStatus, errorThrown);
},
success: function(response){
// Parse valid JSON output here
consolelog(response);
},
});
Vanila Javascript example code.
AJAX request & response:
var data = data: {
header: "#hashtag",
image: "image-blob",
title: "Queen",
name: "Daenerys Targaryen",
assignment: "Crew",
access: "All areas",
};
var xhr = new XMLHttpRequest();
//Send the proper header information along with the request
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//Call a function when the state changes.
xhr.onreadystatechange = function() {
if(this.readyState == XMLHttpRequest.DONE && this.status == 200) {
// Parse valid JSON output here
console.log(JSON.parse(this.responseText));
}else{
// Parse error output here
console.log(this.statusText);
}
}
xhr.open("POST", 'http://api.heimdaldata.dk/badge/', true);
xhr.send(JSON.stringify(data));