Last active
August 31, 2015 23:09
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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