Using BAP creds I am able to pull all my accounts tickets, check content and update. Which API call to use to escalate ticket to SoftLayer?
this is the API service that BAP uses to perform its actions:
http://sldn.softlayer.com/reference/services/SoftLayer_Brand
as you can see there is a method to list the tickets, however there is no a method to create tickets, that is because when you create a ticket using BAP is the same thing like if you would create the ticket using control portal the method used is this:
http://sldn.softlayer.com/reference/services/SoftLayer_Ticket/createStandardTicket
here an example to create tickets using the Softlayer's Python client:
https://softlayer.github.io/python/create_ticket/
using REST:
POST https://$USERNAME:$APIKEY#api.softlayer.com/rest/v3/SoftLayer_Ticket/createStandardTicket
payload:
{
"parameters":[{
"subjectId": 1121,
"assignedUserId": 11111
},"this is my test ticket"]
}
Note: replace assignedUserId with a valid user id
Regards
To escalate a ticket to SoftLayer, you need to follow these steps:
1. Add an update to the ticket
https://$user:$apiKey#api.softlayer.com/rest/v3/SoftLayer_Ticket/21588750/addUpdate
Method: Post
{
"parameters":[
{
"entry":"Escalate to SoftLayer",
"type":
{
"keyName":"AGENT"
}
}
]
}
2. Edit the ticket with the following information:
https://$user:$apiKey#api.softlayer.com/rest/v3/SoftLayer_Ticket/21588750/edit
Method: Post
{
"parameters":[
{
"groupId":1008, "changeOwnerFlag":true
}
]
}
Note: “groupId : 1008” refers to Support group. To get available group identifiers (groupId), try the following rest request:
https://$user:$apiKey#api.softlayer.com/rest/v3/SoftLayer_Ticket/getAllTicketGroups
Method: Get
References:
SoftLayer_Ticket::addUpdate
SoftLayer_Ticket::edit
SoftLayer_Ticket::getAllTicketGroups
Related
I am trying to pass the owner attribute to create a user story in rally using rally API But I am encountering below error.
{
"CreateResult": {
"_rallyAPIMajor": "2",
"_rallyAPIMinor": "0",
"Errors": [
"Cannot parse object reference from \"{\"Owner\": {\"_refObjectName\": \"Ron\"}}\""
],
"Warnings": [
"Ignored JSON element HierarchicalRequirement.PortfolioItem during the processing of this request."
]
}
}
My request payload
{
"HierarchicalRequirement":{
"Name": "hello Wrold",
"Description":" 123 test description",
"Workspace": "/workspace/18686460234",
"Project":"/project/1025697468602323",
"PortfolioItem":"",
"Owner":{"_refObjectName":"Ron"},
"ScheduleState":"Defined"
}
}
Any thoughts?
In general, when referring to an object property that itself is an object (as in this case with the User object), you pass in the actual value of _ref, not another object. If you have previously been passed the reference to the user as a full blown URI, then you can still pass that in and the SDK will convert it to a _ref.
If you go to the webservice docs (https://rally1.rallydev.com/slm/doc/webservice/) for your subscription and go down to the User section, you can get the docs to fetch you some examples of users. The _ref will come back something like:
https://rally1.rallydev.com/slm/webservice/v2.0/user/39776836851
I believe that you can either use that, or just truncate it to the number at the end. So the code will need to be changed so that the Owner line reads:
"Owner" : "https://rally1.rallydev.com/slm/webservice/v2.0/user/39776836851"
I am trying to retrieve all the organizations in my account but in the documentation an organization is always required in the API call.
https://dev.azure.com/{organization}/_apis/...
If you load the current landing page, it displays all your organizations tied to your account. I assumed it had to get that information some way. I captured the network traffic and I believe you could get to the data you want using a system API call. However, it might change or might become unsupported without notice, so use at your own discretion.
You can get the information you want using this API:
Post https://dev.azure.com/{organization1}/_apis/Contribution/HierarchyQuery?api-version=5.0-preview.1
Body:
{
"contributionIds": ["ms.vss-features.my-organizations-data-provider"],
"dataProviderContext":
{
"properties":{}
}
}
Response:
{
"dataProviderSharedData": {},
"dataProviders": {
"ms.vss-web.component-data": {},
"ms.vss-web.shared-data": null,
"ms.vss-features.my-organizations-data-provider": {
"organizations": [
{
"id": "{redacted id}",
"name": "{organization1}",
"url": "https://{organization1}.visualstudio.com/"
},
{
"id": "{redacted id}",
"name": "{organization2}",
"url": "https://dev.azure.com/{organization2}/"
}
],
"createNewOrgUrl": "https://app.vsaex.visualstudio.com/go/signup?account=true"
}
} }
you can do it simply by making a call to get all the account you are member/ owner of. However for that you need your id, which can be easily fetched by making get profile call. Here are steps below:
Make a VSTS API call to get profile details using Bearer token or PAT
https://app.vssps.visualstudio.com/_apis/profile/profiles/me?api-version=5.1
This will return you, your Id:
{
"displayName": "xxxx",
"publicAlias": "xxx",
"emailAddress": "xxx",
"coreRevision": xxx,
"timeStamp": "2019-06-17T09:29:11.1917804+00:00",
"id": "{{We need this}}",
"revision": 298459751
}
Next, make a call to get all the accounts you are member of or owner of:
https://app.vssps.visualstudio.com/_apis/accounts?api-version=5.1&memberId={{Your Id}}
Response:
{
"count": 1,
"value": [
{
"accountId": "xxx",
"accountUri": "xxx",
"accountName": "xxx",
"properties": {}
}
]
}
It will return list of accounts you are associated with.
A REST API request/response pair can be separated into five components:
The request URI, in the following form:
VERB https://{instance}[/{team-project}]/_apis[/{area}]/{resource}?api-version={version}
instance:
The Azure DevOps Services organization or TFS server you're sending the request to.
They are structured as follows:
Azure DevOps Services: dev.azure.com/{organization}
The REST API's are organization specific. This is not documented at present. You could submit a feature request here: https://developercommunity.visualstudio.com/spaces/21/index.html
Our PM and product team will kindly review your suggestion. Sorry for any inconvenience.
As a workaround, you could use the API which captured from network traffic just as Matt mentioned.
We've been using "https://app.vssps.visualstudio.com/_apis/accounts" without specifying any API version and this returns all our accountnames
This is still working for us, but because of some other issues we have I'm adding the api version to all our api calls, however. For this I also run into the fact that https://learn.microsoft.com/en-us/rest/api/azure/devops/account/accounts/list?view=azure-devops-rest-5.0 requires an member or owner id.
Retrieving that needs an account/organization so it is a bit of a catch 22 situation.
For now I'll stay with just "https://app.vssps.visualstudio.com/_apis/accounts" I guess
I'm getting a sign-in response for both "app.vssps.visualstudio.com/_apis/accounts" and
Post https://dev.azure.com/{organization1}/_apis/Contribution/HierarchyQuery?api-version=5.0-preview.1
StatusCode : 203
StatusDescription : Non-Authoritative Information
EDIT:
Nevermind, it worked using the static MSA clientid and replyURL:
internal const string clientId = "872cd9fa-d31f-45e0-9eab-6e460a02d1f1"; //change to your app registration's Application ID, unless you are an MSA backed account
internal const string replyUri = "urn:ietf:wg:oauth:2.0:oob"; //change to your app registration's reply URI, unless you are an MSA backed account
//PromptBehavior.RefreshSession will enforce an authn prompt every time. NOTE: Auto will take your windows login state if possible
result = ctx.AcquireTokenAsync(azureDevOpsResourceId, clientId, new Uri(replyUri), promptBehavior).Result;
Console.WriteLine("Token expires on: " + result.ExpiresOn);
var bearerAuthHeader = new AuthenticationHeaderValue("Bearer", result.AccessToken);
// Headers
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("User-Agent", "ManagedClientConsoleAppSample");
client.DefaultRequestHeaders.Add("X-TFS-FedAuthRedirect", "Suppress");
client.DefaultRequestHeaders.Authorization = authHeader;
//Get Organizations
client.BaseAddress = new Uri("https://app.vssps.visualstudio.com/");
HttpResponseMessage response1 = client.GetAsync("_apis/accounts").Result;
I am trying to retrive security group details (last modified by field) using REST API,but unable to extract this information.
Here is my GET -
GET /Api/rest/2.0/system/security/groups?depth=partial&search=acronym%3DRXCM&xsrfToken=dfa16605-d884-4ebc-9a7b-16fd36c9181a
Response
{
"elements":
[
{
"type":"SecurityGroup",
"id":"29",
"createdAt":"1427641487",
"createdBy":"13",
"depth":"partial",
"name":"Central Marketing User",
"updatedAt":"1427641487",
"acronym":"RXCM",
"isEffective":"false",
"isReadOnly":"false"
}
],
"page":1,
"pageSize":1000,
"total":1
}
Does anyone knows how to get LastModifiedBy field?
You'll get more data on the response if you use the depth=complete instead of partial.
I'm not sure if that will return the LastModifiedBy.
I am new to BPM , softlayer and REST. I completed creating storages (performance and endurance). Now I need to know How will I be able to delete the storages that are not attached to any Virtual Machines. I did not find any thing related to this. Please make a needful favour. Thanks in advance.
Please try the following request:
https://[username]:[apikey]#api.softlayer.com/rest/v3/SoftLayer_Billing_Item_Cancellation_Request/createObject
Method: POST
Json Payload:
{
"parameters": [
{
"accountId": 202019,
"items": [
{
"billingItemId": 65959265,
"immediateCancellationFlag": true
}
]
}
]
}
How to get the billingItemId information and account id?
Execute:
https://[username]:[apikey]#api.softlayer.com/rest/v3/SoftLayer_Network_Storage/4494893/getObject?objectMask=mask[accountId,username,billingItem.id]
Method: GET
If you don’t know the Network Storage id, please execute this request using the username:
https://[username]:[apikey]#api.softlayer.com/rest/v3/SoftLayer_Account/getNetworkStorage?objectFilter={"networkStorage": {"username": {"operation": "storageName"}}}&objectMask=mask[billingItem]
Method: GET
References:
SoftLayer_Billing_Item_Cancellation_Request::createObject
SoftLayer_Network_Storage::getObject
So, I'm trying to show how Restivus API works and Meteor is nice to my colleagues. :)
I've made a simple blog app at http://askar-blog.meteor.com/ (thanks to DiscoverMeteor book).
My repo https://github.com/tenzan/blog
(I'm reading https://github.com/kahmali/meteor-restivus#restivus)
I have three collections:
users
posts
comments
So, post has many comments. Usually, we used to have comments as a nested documents inside of a post, but from the Meteor's nature these two attributes are split up into different collections.
I want to implement a REST API, so that I can access (including CRUD operations) posts and collections in the way:
http://example.com/api/posts - all posts
http://example.com/api/posts/post_id - a specific post
http://example.com/api/posts/post_id/comments - all comments that belongs to a given post
http://example.com/api/posts/post_id/comments/comment_id - a specific comment that belongs to a given post
If you have a look at my repo, you will see there're posts.js and comments.js under lib/collections.
As I understood, to enable REST API, I will need the following snippet in the posts.js:
if (Meteor.isServer) {
// Global API configuration
var Api = new Restivus({
useDefaultAuth: true,
prettyJson: true
});
// Generates: GET, POST on /api/post and GET, PUT, DELETE on
// /api/items/:id for the Posts collection
Api.addCollection(Posts);
// Generates: POST on /api/users and GET, DELETE /api/users/:id for
// Meteor.users collection
Api.addCollection(Meteor.users, {
excludedEndpoints: ['getAll', 'put'],
routeOptions: {
authRequired: true
},
endpoints: {
post: {
authRequired: false
},
delete: {
roleRequired: 'admin'
}
}
});
As you see, I've added Api.addCollection(Posts); and I've confirmed I can access all posts or a specific one.
My questions:
1- How can I setup API to access comments for their parent post?
2 - Will I have to have to following code to access posts ? I'm asking because, I'm already able to access them as I have Api.addCollection(Posts); :
Maps to: /api/posts/:id
Api.addRoute('posts/:id', {authRequired: true}, {
get: function () {
return Posts.findOne(this.urlParams.id);
},
delete: {
roleRequired: ['author', 'admin'],
action: function () {
if (Articles.remove(this.urlParams.id)) {
return {status: 'success', data: {message: 'Post removed'}};
}
return {
statusCode: 404,
body: {status: 'fail', message: 'Post not found'}
};
}
}
});
I apologise, I got confused myself trying to figure out the correct way of making a REST API.
Please feel free to add anything important on this regard I have missed here.
I've discussed with the author of the package
https://github.com/kahmali/meteor-restivus/issues/128
The feature is being developed
https://github.com/kahmali/meteor-restivus/issues/70