Skip to content

Instantly share code, notes, and snippets.

@boomtrain-support
Last active August 31, 2015 23:09
Show Gist options
  • Save boomtrain-support/b7e8281eabe1b868dd61 to your computer and use it in GitHub Desktop.
Save boomtrain-support/b7e8281eabe1b868dd61 to your computer and use it in GitHub Desktop.
POST /resources/:model - Create a new Resource with the specified model type using jQuery
<script>
// Create a new Resource of the specified model type
function postResourcesModel() {
// JSON stringify the data
var json_data = JSON.stringify({
'id': '{Resource ID}',
'props': {
'url': '{The Canonical URL}',
'title': '{The Title of the Resource}',
'thumbnail': '{URL to the Hosted Image}',
...
}
});
// Send a jQuery AJAX request to create the new resource for the specified model
$.ajax({
url: 'https://events.boomtrain.com/resources/{model}',
// Replace your Username, Password, and App Id
headers: {
'x-app-id': '{app_id}',
'Content-Type': 'application/json',
'Authorization': 'Basic ' + btoa('{username}:{password}')
},
type: 'POST',
data: json_data,
success: function(msg) {
console.log(msg);
}
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment