Created
August 31, 2016 15:13
-
-
Save kuckmc01/7419ac26f82644b20497e571dcf161a7 to your computer and use it in GitHub Desktop.
AEM - Create a resource with sling post using ajax or curl
This file contains 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
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