I try to get all results of a TestCase via API. In the UI I see a list of all results of a TC via the following url:
https://dev.azure.com/xxx/yyyy/_testPlans/_results?testCaseId=48587
How can I do this via API?
How can I do this via API?
I am afraid that you couldn't find this API in Official document.
But you could get the API in Browser console:
Here are the API and Request Body:
API URL:
POST https://dev.azure.com/{OrganizationName}/_apis/Contribution/HierarchyQuery?excludeUrls=true&enumsAsNumbers=true&msDateFormat=true&noArrayWrap=true&api-version=5.0-preview.1
Request Body:
{
"contributionIds":["ms.vss-test-web.testcase-results-data-provider"],
"dataProviderContext":
{"properties":
{
"testCaseId":testcaseid,
"sourcePage":{"url":"https://dev.azure.com/{OrganizationName}/{ProjectName}/_testPlans/execute?planId={TestPlanId}&suiteId={Test SuiteID}","routeId":"ms.vss-test-web.testplans-hub-refresh-route","routeValues":{"project":"{ProjectName}","pivots":"execute","controller":"ContributedPage","action":"Execute"}}
}
}
}
Result:
If you want to get detailed info, you could pass the Test Run id and test result ID to Rest API: Results - Get
Related
So basically I need to use the update/revise Rest API to update the fields in the vTiger CRM.
But when I am using the rest API (link : https://help.vtiger.com/article/147111249-Rest-API-Manual) to update the fields, I am getting the error as "400 Unsupported operations: The request cannot be fulfilled due to bad syntax."
My api : endpoint/reviseelement=convert_into_json_string({id:5x369, potentialname:'demo2'})
Also apart from this, I had used the SQL query Rest API, to update the record in the modules, but it is also giving me the same error as: "400 Unsupported operations: The request cannot be fulfilled due to bad syntax."
My Api query : endpoint/query?query=UPDATE Potentials SET potentialname = 'demo2 where id = 5x369;
Also by using the webservice(https://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html) rest api I am getting error like : "Permission to perform the operations is denied for id: ".
So how can I use the update api. Can anyone please help?
For web services API (https://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html),
When you pass the payload data, make sure you're passing the x-www-form-urlencoded form of data.
Also, make sure you're passing 'element' argument with value like this:
{"id": "10x11471458", "leadsource": "Facebook"}.
if you're still facing this issue, you can share more details and I'll be happy to help you.
If you still need to do this the following should work.
Method: POST
End Point: /revise
Headers: "Authorization: Basic YOUR_TOKEN"
Body:
{
"element": {
"id":"5x369",
"potentialname": "demo2"
}
}
reference: https://www.vtiger.com/docs/rest-api-for-vtiger#/Revise
I'm using the search API for Google Photos documented here. I'd like the results in the response to be sorted from newest to oldest, but by default, the results are sorted from oldest to newest. Is there a way to reverse the sorting?
I believe your goal as follows.
You want to sort the result values from the method of "Method: mediaItems.search".
You want to sort the values from oldest to newest.
Issue and workaround:
Unfortunately, in the current stage, it seems that there is no parameter for sorting the returned values for the the method of "Method: mediaItems.search" in Google Photos API. Also, it seems that such parameter is not existing in the method of "mediaItems.list".
By the way, it was found that when albumId is used in the request body for the method of "Method: mediaItems.search", the returned values are sorted as the ascending order. If you use the albumn ID, I think that your goal can be achieve by this.
On the other hand, when albumId is NOT used in the request body, the returned values are sorted as the descending order. And also, it seems that when filteres is used in the request body, the returned values are sorted as the descending order.
From your question, I thought that in your situation, albumId might be not used. So in this case, as the current workaround, how about sorting the values using a script after the values are retrieved? In this answer, I would like to propose to use the Web Apps created by Google Apps Script as a wrapper API.
Usage:
1. Create new project of Google Apps Script.
Sample script of Web Apps is a Google Apps Script. So please create a project of Google Apps Script.
If you want to directly create it, please access to https://script.new/. In this case, if you are not logged in Google, the log in screen is opened. So please log in to Google. By this, the script editor of Google Apps Script is opened.
2. Linking Cloud Platform Project to Google Apps Script Project.
About this, you can see the detail flow at here.
And also, please enable Google Photos API at API console.
3. Add scope.
In this case, please addt the scope of https://www.googleapis.com/auth/photoslibrary to the manifest file (appsscript.json).
4. Script.
Please copy and paste the following script (Google Apps Script) to the script editor. This script is for the Web Apps. This Web Apps is used as an API.
function doGet(e) {
const key = "sampleKey"; // This is used for using this Web Apps.
try {
if (e.parameter.key != key) throw new Error("Invalid key.");
const albumId = e.parameter.albumId;
const filters = e.parameter.filters;
const sort = e.parameter.sort;
const headers = {"Authorization": "Bearer " + ScriptApp.getOAuthToken()};
const url = "https://photoslibrary.googleapis.com/v1/mediaItems:search";
let mediaItems = [];
let pageToken = "";
const metadata = {pageSize: 100, pageToken: pageToken};
if (albumId) metadata.albumId = albumId;
if (filters) metadata.filters = JSON.parse(filters);
do {
const params = {
method: "post",
headers: headers,
contentType: "application/json",
payload: JSON.stringify(metadata),
}
const res = UrlFetchApp.fetch(url, params);
const obj = JSON.parse(res.getContentText());
mediaItems = mediaItems.concat(obj.mediaItems);
pageToken = obj.nextPageToken || "";
} while (pageToken);
if (mediaItems.length > 0) {
if (sort && sort == "ascending") {
mediaItems.sort((a, b) => new Date(a.mediaMetadata.creationTime) < new Date(b.mediaMetadata.creationTime) ? -1 : 1);
}
return ContentService.createTextOutput(JSON.stringify({values: mediaItems}));
}
return ContentService.createTextOutput(JSON.stringify({error: "No values."}));
} catch(err) {
return ContentService.createTextOutput(JSON.stringify({error: err.message}));
}
}
5. Deploy Web Apps.
The detail information can be seen at the official document.
On the script editor, at the top right of the script editor, please click "click Deploy" -> "New deployment".
Please click "Select type" -> "Web App".
Please input the information about the Web App in the fields under "Deployment configuration".
Please select "Me" for "Execute as".
This is the important of this workaround.
Please select "Anyone" for "Who has access".
In this case, the user is not required to use the access token. So please use this as a test case.
When you want to use the access token, please set it to Anyone with Google account or Only myself. By this, the user can access to the Web Apps using the access token. When you use the access token, please include the scope of https://www.googleapis.com/auth/drive.readonly or https://www.googleapis.com/auth/drive.
Please click "Deploy" button.
When "The Web App requires you to authorize access to your data" is shown, please click "Authorize access".
Automatically open a dialog box of "Authorization required".
Select own account.
Click "Advanced" at "This app isn't verified".
Click "Go to ### project name ###(unsafe)"
Click "Allow" button.
Copy the URL of Web App. It's like https://script.google.com/macros/s/###/exec.
When you modified the Google Apps Script, please redeploy as new version. By this, the modified script is reflected to Web Apps. Please be careful this.
6. Testing.
As the test of this Web Apps, I would like to propose to use the following curl command. Please replace https://script.google.com/macros/s/###/exec with your Web Apps URL.
Simple use:
In this curl command, the result value is returned as the ascending order of oldest to newest.
$ curl -GL -d "key=sampleKey" -d "sort=ascending" https://script.google.com/macros/s/###/exec
Use albumId:
When you want to use the album ID, please use the following curl command.
$ curl -GL -d "albumId=###" -d "key=sampleKey" -d "sort=ascending" https://script.google.com/macros/s/###/exec
In this case, even when -d "sort=ascending" is not used, the result value is returned as the ascending order of oldest to newest.
Use filters:
When you want to use the filters, please use the following curl command.
$ curl -GL -d 'filters={"dateFilter":{"ranges":[{"startDate":{"year":2020},"endDate":{"year":2021}}]}}' -d "key=sampleKey" -d "sort=ascending" https://script.google.com/macros/s/###/exec
In this command, the values of 2020 - 2021 are returned as the ascending order of oldest to newest.
Note:
Although when I searched this at the Google issue tracker, I couldn't find about it. So how about reporting this as the future request? Ref
References:
Method: mediaItems.search
Related thread.
How to use Google Photos API Method: mediaItems.search in Google apps script for a spreadsheet
Google photos api adding photos not working, upload seems to work
Google Apps Scripts: import (upload) media from Google Drive to Google Photos?
Using the wso2/scim/Users endpoint as described in doc i am supposed to get a response like this one
{
"schemas":[
"urn:scim:schemas:core:1.0"
],
"totalResults":2,
"Resources":[
{
"id":"0032fd29-55a9-4fb9-be82-b1c97c073f02",
"userName":"hasinitg",
"meta":{
"lastModified":"2016-01-26T16:46:53",
"created":"2016-01-26T16:46:53",
"location":"https://localhost:9443/wso2/scim/Users/0032fd29-55a9-4fb9-be82-b1c97c073f02"
}
},
{
"id":"b228b59d-db19-4064-b637-d33c31209fae",
"userName":"pulasthim",
"meta":{
"lastModified":"2016-01-26T17:00:33",
"created":"2016-01-26T17:00:33",
"location":"https://localhost:9443/wso2/scim/Users/b228b59d-db19-4064-b637-d33c31209fae"
}
}
]
}
But i need some extra info for every user and doing subsequent requests for every user using the id to get the extra information (like an email) is too bad.
Is it possible to configure the endpoint response so that i get the information needed for the users in one request ?
You should be able to do this with SCIM extensions.
This blog post has more details.
In WSO2 Identity server 5.3.0, you can achieve this by using the attributes query parameter.
eg. Following request will list all users along with their given names in a single call.
curl -k --user admin:admin 'https://localhost:9443/wso2/scim/Users?attributes=givenname'
Please refer the post here for more details.
Whenever I run following from command line
newman run https://www.getpostman.com/collections/abcd1234
I get output displaying the statistics of failed and execute.
But I am looking for the complete HTML or JSON response from the URL to be printed on terminal after executing the above Newman query.How can I achieve this?
You have to add some log output in your requests.
For the requests where you want to see the response output add the following in the Postman Tests tab:
console.log(responseBody); // full response body
If you want to log a specific part you have to parse the response body into a JSON object:
let response = JSON.parse(responseBody);
console.log(reponse.myprop); // part of the full response body
Now if you run this collection with newman the CLI reporter will print the console log parts as well.
You need to use Postman API.
So you need to run something like this
newman run https://api.getpostman.com/collections/myPostmanCollectionUid?apikey=myPostmanApiKey
(see http://blog.getpostman.com/2018/06/21/newman-run-and-test-your-collections-from-the-command-line/)
You can get ApiKey in your Postman Cloud. You need to go to the workspace -> Integrations -> Browse Integrations -> Postman API View details -> Detail Get API Key/Existing API Keys
If you also need to add environment (if you use Variables), what you need is to run the same command with -e parameter 'newman run https://api.getpostman.com/collections/myPostmanCollectionUid?apikey=myPostmanApiKey -e dev_environment.json'
But what if you have your environment in the cloud as well? According to this document https://www.getpostman.com/docs/v6/postman/collection_runs/command_line_integration_with_newman you can pass URL as value. So you may run something like this
newman run https://api.getpostman.com/collections/myPostmanCollectionUid?apikey=myPostmanApiKey -e environments/{{environment_uid}}?apikey=myPostmanApiKey
It worked for me, hope this will help
I am using newman for webservices and microservices testing. This works fine for me.
summary.run.executions[0].response.text().toString()
After done event you should be able to get the response.
d is the collection exported from Postman.
newman.run({
collection: d,
// reporters: 'cli',
iterationCount: 1,
timeoutRequest: 10000,
timeoutScript: 5000,
delayRequest: 0,
insecure: false,
}).on('done', (err, summary) => {
if (err || summary.error) {
console.error('\ncollection run encountered an error.');
reject(summary.error);
}
else {
var xml = summary.run.executions[0].response.text().toString();
console.log(xml)
}
})
})
Trying to get autocomplete to work in my app when searching for companies.
In my case i am searching for "ska"
Three (3) diffenrent scenarios:
1 - Go to https://www.linkedin.com/ta/federator?types=company&query=ska in your browser.
Result: You get json response with data.
2. Try calling it via javascript
Front-End
$("#birds").autocomplete({
minLength: 3,
source: function (request, response) {
// request.term is the term searched for.
// response is the callback function you must call to update the autocomplete's
// suggestion list.
$.ajax({
url: "https://www.linkedin.com/ta/federator?types=company",
data: { query: request.term },
dataType: "json",
success: response,
error: function () {
response([]);
}
});
}
});
Result: Null
Scenario 3:
Make a call to the LinkedIn API with your APi and secret key.
API Call the "company-search?keywords={your-partial-word}"
Result: The searchhits is nothing like the autocomplete. The autocomplete suggestions are much better.
Suggestions on how to build a autocomlete for LinkedIn when searching for comapnies only.
As mentioned there are two different ways.
Calling the https://www.linkedin.com/ta/federator?types=company&query={name}
Using LinkedIn API - not good nor expected result as shown when using (1)
I think a good way to do this is:
Build a local server, which could handle your request to query, and send your query to linkedin query url(This would eliminate the CORS problem)
In that autocomplete js code, set the url to be your local server.