check status of job requested through travis API v3 - api

So I've submitted a request using travis api v3 guide and got response like:
{
"#type": "pending",
"remaining_requests": 10,
"repository": {
"#type": "repository",
"#href": "/repo/111111111",
"#representation": "minimal",
"id": 111111111,
"name": "my-111111111",
"slug": "me/my111111111"
},
"request": {
"repository": {
"id": 222222,
"owner_name": "me",
"name": "my-111111111"
},
"user": {
"id": 333333
},
"id": 444444,
"message": "Cool message",
"branch": "master"
},
"resource_type": "request"
}
So what is the way to get status of those jobs now? I suppose that I need to use id 444444, but I am getting error below, not sure what I am doing wrong:
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token mycooltoken" \
https://api.travis-ci.org/repo/111111111/requests/444444
{
"#type": "error",
"error_type": "not_found",
"error_message": "resource not found (or insufficient access)"
}
Can somebody point me where to look for examples or any other idea?

Oh sorry for confusion - somehow I overlooked that I must change POST to GET; with that simple fix everything worked fine.

Related

How to create contact point in grafana using API?

I am trying to create a contact point in grafana for pagerduty using grafana API.
Tried with the help of these URLS: AlertProvisioning HTTP_API
API call reference
YAML reference of data changed to JSON and tried this way, the YAML reference
But getting error as
{"message":"invalid object specification: type should not be an empty string","traceID":"00000000000000000000000000000000"}
My API code below, replaced with dummy integration key for security.
curl -X POST --insecure -H "Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -H "Content-Type: application/json" -d '{
"contactPoints": [
{
"orgId": 1,
"name": "test1",
"receivers": [
{
"uid": "test1",
"type": "pagerduty",
"settings": {
"integrationKey": "XXXXXXXXXXXXXXXX",
"severity": "critical",
"class": "ping failure",
"component": "Grafana",
"group": "app-stack",
"summary": "{{ `{{ template \"default.message\" . }}` }}"
}
}
]
}
]
},
"overwrite": false
}' http://XXXXXXXXXXXXXXXX.us-east-2.elb.amazonaws.com/api/v1/provisioning/contact-points
I would recommend to enable Grafana swagger UI. You will see POST /api/v1/provisioning/contact-points model there:
Example:
{
"disableResolveMessage": false,
"name": "webhook_1",
"settings": {},
"type": "webhook",
"uid": "my_external_reference"
}

Cannot create new Pipeline using Az DevOps Pipelines API 6.0-preview.1

I'm trying to create new Pipelines using this API endpoint:
POST https://dev.azure.com/{organization}/{project}/_apis/pipelines?api-version=6.0-preview.1
This is the request I'm using:
curl -X POST \
'https://dev.azure.com/<myorg>/<myproj>/_apis/pipelines?api-version=6.0-preview.1' \
-H 'Authorization: Basic <b64string>' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"configuration":{
"repository": {
"id": "<repo-guid>",
"name": "<repo-name>",
"type": "azureReposGit"
},
"path": "pipeline.yaml",
"type": "yaml"
},
"folder": "\\custompath\\",
"name": "<pipelinename>"
}
I keep getting the same error:
{
"$id": "1",
"innerException": null,
"message": "Value cannot be null.\r\nParameter name: repositoryName",
"typeName": "System.ArgumentNullException, mscorlib",
"typeKey": "ArgumentNullException",
"errorCode": 0,
"eventId": 0
}
It seems an issue with my payload, but documentation isn't very helpful about it
https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/create?view=azure-devops-rest-6.0
Current version o nodejs sdk doesn't support the Pipeline API yet. Can anyone help me?
I'm able to reproduce your issue on my side, and have reported this issue at website below:
https://developercommunity.visualstudio.com/content/problem/1101376/create-pipeline-rest-api-does-not-work.html
Product team has provided response that "A fix for this issue has been prepared. It should be released to everyone within the next 3 weeks."

How can assign permission to user for specific folder in nuxeo using rest api

I upload many files to Nuxeo server using rest API. Now I need to add permission to users. I use http://localhost:8080/nuxeo/api/v1/id/file-id/#acl endpoint with payload:
{
"username": "username",
"permission": "ReadWrite"
}
But it is not working. The error is:
{
"entity-type": "exception",
"status": 405,
"message": "javax.ws.rs.WebApplicationException"
}
How can I do it? Is there any endpoint for that?
Permission can be added by the Document.AddPermission operation available on the http://localhost:8080/nuxeo/api/v1/automation/Document.AddPermission endpoint.
Here is a curl example call used to add ReadWrite permission for editor user to the document with ID 2d28e87f-0753-4cfc-9f9b-b17d424aa6a7:
curl -X POST -u Administrator:Administrator \
http://localhost:8080/nuxeo/api/v1/automation/Document.AddPermission \
-H "Content-Type: application/json" \
-d '{"params":{"users":["editor"],"permission":"ReadWrite"},"input":"2d28e87f-0753-4cfc-9f9b-b17d424aa6a7"}'
And here is an example payload when you want to add permission for external user:
{
"params": {
"users":[],
"email": "some-external#user.com",
"permission": "Read",
"begin": "2020-06-01T00:00:00+02:00",
"end": "2020-06-30T00:00:00+02:00",
"notify": true,
"comment": "notify#me.com"},
"context": {},
"input": "2d28e87f-0753-4cfc-9f9b-b17d424aa6a7"
}

Ansible- AWX login token API

I have installed Ansible-AWX and configured certain playbooks. I want to use the AWX API to run the ansible playbooks on a .net console application. However in order to do so I need a oauth token to login using the postman API. The problem is I am not able to generate the token. I have tried using the AWX cli and few other approaches still no positive results.
Any leads would be appreciated.
Give it a shot here: curl -ku username:password -H "Content-Type: application/json" -X POST -d '{"description":"Tower CLI", "application":null, "scope":"write"}' http:///api/v2/users/1/personal_tokens/ | jq -r .token
https://github.com/ansible/tower-cli/issues/478#issuecomment-370528556
$ curl -ku ryan:ryan -H "Content-Type: application/json" -X POST -d '{"description":"Tower CLI", "application":null, "scope":"read"}' https://awx.example.org/api/v2/users/1/personal_tokens/ | python -m json.tool
{
"application": null,
"created": "2018-03-05T19:06:56.224538Z",
"description": "Tower CLI",
"expires": "2018-03-06T05:06:56.223889Z",
"id": 4,
"modified": "2018-03-05T19:06:56.234208Z",
"refresh_token": null,
"related": {
"activity_stream": "/api/v2/tokens/4/activity_stream/",
"user": "/api/v2/users/1/"
},
"scope": "read",
"summary_fields": {
"user": {
"first_name": "",
"id": 1,
"last_name": "",
"username": "ryan"
}
},
"token": "ABy5N1fBiPujilEJjAUtmPlK8mTdGr",
"type": "o_auth2_access_token",
"url": "/api/v2/tokens/4/",
"user": 1
}

How to add test steps in a test case work item using Rest API - TFS2018 / Python

I am using Microsoft's TFS 2018 and I have started writing some Selenium test cases using Python 3.7 in Visual Studio 2018.
I have managed to use the REST API of TFS to return my TFS projects and create new test cases.
What I couldn't find is how to use this API to pass a list with all the test steps of this test case. I am not sure how and if you can add them in the body of the request as a string or array.
At the moment I am trying to make this work on Postman first and then I am going to try in python as well.
This is the request:
curl -X POST \
'https://TFSLINK:443/DefaultCollection/TFS/_apis/wit/workitems/$Test%20Case?api-version=4.1' \
-H 'Authorization: Basic MYKEY' \
-H 'Content-Type: application/json-patch+json' \
-H 'cache-control: no-cache' \
-d '[
{
"op": "add",
"path": "/fields/System.Title",
"from": null,
"value": "Sample task 2"
}
]'
Is there a way to achieve adding steps ? The API didn't mention anything about this.
In the response I get after creating a test case I get a section called 'fields' which should have included the steps but I can't see them in my response.
{
"id": 731,
"rev": 1,
"fields": {
"System.AreaPath": "TFS",
"System.TeamProject": "TFS",
"System.IterationPath": "TFS",
"System.WorkItemType": "Test Case",
"System.State": "Design",
"System.Reason": "New",
"System.AssignedTo": "Marialena <TFS\\marialena>",
"System.CreatedDate": "2019-01-09T08:00:50.51Z",
"System.CreatedBy": "Marialena <TFS\\marialena>",
"System.ChangedDate": "2019-01-09T08:00:50.51Z",
"System.ChangedBy": "Marialena <TFS\\marialena>",
"System.Title": "Sample task 2",
"Microsoft.VSTS.Common.StateChangeDate": "2019-01-09T08:00:50.51Z",
"Microsoft.VSTS.Common.ActivatedDate": "2019-01-09T08:00:50.51Z",
"Microsoft.VSTS.Common.ActivatedBy": "Marialena <TFS\\marialena>",
"Microsoft.VSTS.Common.Priority": 2,
"Microsoft.VSTS.TCM.AutomationStatus": "Not Automated"
},
"_links": {
"self": {
"href": "https://TFSLINK/DefaultCollection/_apis/wit/workItems/731"
},
"workItemUpdates": {
"href": "https://TFSLINK/DefaultCollection/_apis/wit/workItems/731/updates"
},
"workItemRevisions": {
"href": "https://TFSLINK/DefaultCollection/_apis/wit/workItems/731/revisions"
},
"workItemHistory": {
"href": "https://TFSLINK/DefaultCollection/_apis/wit/workItems/731/history"
},
"html": {
"href": "https://TFSLINK/web/wi.aspx?pcguid=07b658c4-97e5-416f-b32d-3dd48d7f56cc&id=731"
},
"workItemType": {
"href": "https://TFSLINK/DefaultCollection/18ca0a74-cf78-45bf-b163-d8dd4345b418/_apis/wit/workItemTypes/Test%20Case"
},
"fields": {
"href": "https://TFSLINK/DefaultCollection/_apis/wit/fields"
}
},
"url": "https://TFSLINK/DefaultCollection/_apis/wit/workItems/731"
}
I have tried creating this PATCH request to update the steps but it didn't work
curl -X PATCH \
'https://TFSLINK:443/DefaultCollection/TFS/_apis/wit/workItems/730?api-version=4.1' \
-H 'Authorization: Basic MYKEY' \
-H 'Content-Type: application/json-patch+json'
-d '[
{
"op": "add",
"path": "/fields/Microsoft.VSTS.TCM.Steps",
"from": null,
"value": "Test"
},
{
"op": "add",
"path": "/fields/Steps",
"from": null,
"value": "Test"
}
]'
And maybe this is a another topic but if the above is achievable, can you also pass the results after you run the test and update the test plan perhaps ? If this is unrelated please help me only with the test steps and ignore this question.
Many thanks.
This is the way to add test steps in Test Case with Rest API:
{
"op": "add",
"path": "/fields/Microsoft.VSTS.TCM.Steps",
"value": "<steps id=\"0\" last=\"1\"><step id=\"2\" type=\"ValidateStep\"><parameterizedString isformatted=\"true\">Input step 1</parameterizedString><parameterizedString isformatted=\"true\">Expectation step 1</parameterizedString><description/></step></steps>"
}
For a few steps (3 on this example):
{
"op": "add",
"path": "/fields/Microsoft.VSTS.TCM.Steps",
"value": "<steps id=\"0\" last=\"4\"><step id=\"2\" type=\"ValidateStep\"><parameterizedString isformatted=\"true\"><P>step 1 \"Action\"</P></parameterizedString><parameterizedString isformatted=\"true\"><P>step 1 \"Expected\"<BR/></P></parameterizedString><description/></step><step id=\"3\" type=\"ValidateStep\"><parameterizedString isformatted=\"true\"><P>step 2 \"Action\"<BR/></P></parameterizedString><parameterizedString isformatted=\"true\"><P>step 2 \"Expected\"<BR/></P></parameterizedString><description/></step><step id=\"4\" type=\"ValidateStep\"><parameterizedString isformatted=\"true\"><P>step 3 \"Action\"<BR/></P></parameterizedString><parameterizedString isformatted=\"true\"><P>step 3 \"Expected\"<BR/></P></parameterizedString><description/></step></steps>"
}