Skip to content

Instantly share code, notes, and snippets.

@alexmwalker
Created March 6, 2025 23:03
Show Gist options
  • Save alexmwalker/abcd1862856e1497be2e704ea301b4cd to your computer and use it in GitHub Desktop.
Save alexmwalker/abcd1862856e1497be2e704ea301b4cd to your computer and use it in GitHub Desktop.
javascript:(function() {
var title = prompt("Enter the title of the new item:");
var description = prompt("Enter the description of the new item:");
if (title && description) {
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://dev.azure.com/{your-organization}/{your-project}/_apis/wit/workitems/$v2?api-version=6.1");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Basic " + btoa("{your-personal-access-token}:"));
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
alert("Item created successfully!");
} else {
alert("Error creating item: " + xhr.statusText);
}
};
xhr.onerror = function() {
alert("Error creating item: Network error.");
};
var data = [
{
"op": "add",
"path": "/fields/System.Title",
"value": title
},
{
"op": "add",
"path": "/fields/System.Description",
"value": description
},
{
"op": "add",
"path": "/fields/System.State",
"value": "New"
},
{
"op": "add",
"path": "/fields/System.IterationPath",
"value": "Backlog" // Replace with your desired iteration path
},
{
"op": "add",
"path": "/fields/System.Tags",
"value": "WebDev" // Adding the 'WebDev' tag
}
];
var jsonData = JSON.stringify(data);
xhr.send(jsonData);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment