Skip to content

Instantly share code, notes, and snippets.

@kuckmc01
Created August 31, 2016 15:13
Show Gist options
  • Save kuckmc01/7419ac26f82644b20497e571dcf161a7 to your computer and use it in GitHub Desktop.
Save kuckmc01/7419ac26f82644b20497e571dcf161a7 to your computer and use it in GitHub Desktop.
AEM - Create a resource with sling post using ajax or curl
var samplePost = function(url,data){
console.log(data);
$.ajax({
url : url,
type: "POST",
data: data,
success: function (data,textStatus,xhr) {
console.log('success');
if(textStatus == 'success'){
console.log('ok')
}
},
error: function (jXHR, textStatus, errorThrown) {
console.log('error:',jXHR, textStatus, errorThrown);
}
});
};
var url = '/content/path/to/new/resource';
var data = {
'sling:resourceType' : 'new/resource/type',
'propertyName' : 'property'
};
samplePost(url,data);
//curl -F"sling:resourceType=new/resource/type" -F"propertyName=property" http://admin:admin@localhost:4502/content/path/to/new/resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment