Dear all,
I'm trying to make a POST request to the VSO REST API by using jQUery and AJAX. Here's my code:
var bearing = "Bearer " + $('textarea#accesstoken').val();
var dataJSON = {"name": "FabrikamTravel","description": "Frabrikam travel app for Windows Phone","capabilities": {"versioncontrol": {"sourceControlType": "Git"},"processTemplate": {"templateTypeId": "6b724908-ef14-45cf-84f8-768b5384da45"}}};
$.ajax({
url: 'https://chriwil.visualstudio.com/DefaultCollection/_apis/projects?api-version=2.0-preview',
dataType: 'JSON',
type: 'POST',
data: JSON.stringify(dataJSON),
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", bearing)
},
success: function(data){
console.log(data)
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus);
}
});When I send the request, I get the message: "Failed to load resource: the server responded with a status of 403 (Forbidden)".
Does anyone know how to fix this? It works with a GET request fine.
Thank you.
Christopher