We have many dozens of build pipelines and we want to pause and resume (re-enable) build pipelines from a simple webapp interface as we are making config changes frequently. Here is the MS doc explaining this API:
https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/update%20build?view=azure-devops-rest-5.0#definitionqueuestatus
From this documentation, it appears I need to hit the REST API and change/toggle the DefinitionQueueStatus -- however, this documentation only shows a sample for a build specific operation, whereas I want to pause then re-enable the entire build pipeline. What is the proper way to make this call?
I'm using fetch - and I've tried many dozen formats in the call - the 'ourorg' and 'ourproject' are correct (we use this call structure for many other calls), but all fails for this call below. I grabbed the 'definitionID' from the URL I can visibly see when in the Azure devops portal on the specific build pipeline page, and I'm using it for the {buildID} as I don't know what else to put there. Any guidance to help here is appreciated - I don't need to use fetch btw - any working sample will help here:
fetch(https://dev.azure.com/our_org/our_projectname/_apis/build/builds/definitionId=1593?retry=true&api-version=5.0 {
method: 'PATCH ',
credentials: 'same-origin',
body: 'DefinitionQueueStatus: "Enabled"'
}).then(function(response) {
console.log(response);
})
It seems that the body is incorrect in your post. Here is sample about how to use POSTMAN to access Azure DevOps Services REST APIs.
Generate the PAT, and then record the token, it is important to use to authorization, please see this document.
Create a new request in POSTMAN, it is recommended to put the request in a collection for Azure DevOps Services REST API;
Select the authorization as Basic Auth, you can input the username as any value, and the password as the token which is generated in step1.
Basic Auth
Set the REST API which you want to use,and select the request method type(GET,POST,FETCH ....), here you use https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=5.0.
In the Body tab, you can set the request body as raw in json format, and input the value as following:
{
"buildNumber":"#20190607.2",
"buildNumberRevision":1,
"definition":
{
"id":1,
"createdDate":null,
"queueStatus":"paused"
}
}
Everthing is ready now, you can send the request, if sccuess, you will get the response from the REST API.
In your post, the body content is incorrect, the Request Body should meet the format in the REST API document. The DefinitionQueueStatus is a type in definitions. In addition, if you send the request with parameter retry, you will get the message The request body must be empty when the retry parameter is specified..
Related
I am using Google Form API to create a sample project to create, update & get responses to a form.
I am using the following documentation for reference and understanding:
https://developers.google.com/forms/api/reference/rest/v1/forms.responses
It mentions that a single response body (using response ID) includes the respondent email, but each time I trigger the API, the respondent email is undefined and hence does not get returned in the response body.
What am I doing wrong?
Please note I am not using the Apps Script. I am using the API in a node.js project.
Thank you
The Google Cloud Build - Webhook Trigger create trigger documentation shows the proper URL to POST to invoke the build trigger. However the documentation does not describe the POST body, which seems to be required. I have successfully triggered the cloud build webhooks using content-type: application/json header with a POST body of {}, but it would be nice to know:
What is the POST body supposed to be?
Are we able to pass substitution variables in the POST body?
The Google Cloud Build - REST API documentation provides some additional hints that a HttpBody payload is accepted, but no additional information past that as for as I can tell.
The body is what you want! In fact, in your trigger you customize your substitution variable like this (from the documentation)
--subtitutions=\
_SUB_ONE='$(body.message.test)', _SUB_TWO='$(body.message.output)'
So, your body need to be like that
{
"message": {
"test": "test value",
"ourput": "my output"
}
}
The data are automatically extracted from your body content. So you can add more substitutions or change the format of your JSON and thus of your substitutions value.
I'm in the process of creating an Azure Logic App to work with Abbyy's OCR REST API.
I use the Create SAS URI by path action which returns Web URL. Web URL returns the FQDN, incuding the SAS token, to my blob.
Web URL is passed to an Http action as a query parameter. In code view, the relevant part of the JSON looks like:
"method": "GET",
"uri": "https://cloud.ocrsdk.com/processRemoteImage?source=#{body('Create_SAS_Uri_by_path')?['WebUrl']}&language=English&exportformat=pdfSearchable&description=blah&imageSource=scanner"
The uri resolves thus:
https://cloud.ocrsdk.com/processRemoteImage?source=https://mysaaccount.blob.core.windows.net/inbox/180730110047_0001.pdf?sv=2017-04-17&sr=b&sig=2IGMt1qDZthaBSyvD3WJ6T1zc36Wr%2FNoiB4Wki5Lf28%3D&se=2018-08-16T11%3A16%3A48Z&sp=r&language=English&exportformat=pdfSearchable&description=blah&imageSource=scanner"
This results in the error (450):
<?xml version="1.0" encoding="utf-8"?><error><message language="english">Invalid parameter: sr</message></error>
Which is basically picking up sr= query parameter from the SAS token and of course, the API doesn't have an sr argument, and even if it did, its value would be wrong.
I did find this question and I attempted "percent-escape" the ampersands (&) by adjusting my code to use the replace function, thus:
"method": "GET",
"uri": "https://cloud.ocrsdk.com/processRemoteImage?source=#{replace(body('Create_SAS_Uri_by_path')?['WebUrl'],'%26','%2526' )}&language=English&exportformat=pdfSearchable&description=blah&imageSource=scanner"
However, this has no effect. I.e the resulting URI is the same as above. Interestingly, it appears the SAS token itself has made use of "percent-escape".
If anyone has any suggestion on how to resolve or work around this problem, I'd be most greatful if you would share your thoughts.
Does anyone know if the LogicApp actions are opensource and if so what the GitHub link is. I can then raise an issue.
Resolved it.
Basically, I was on the right track, but I used %26 when I should have used &, so using the code above, it should read:
"method": "GET",
"uri": "https://cloud.ocrsdk.com/processRemoteImage?source=#{replace(body('Create_SAS_Uri_by_path')?['WebUrl'],'&','%26' )}&language=English&exportformat=pdfSearchable&description=blah&imageSource=scanner"
And therefore, the URI reads:
https://cloud.ocrsdk.com/processRemoteImage?source=https://mysaaccount.blob.core.windows.net/intray/180730110047_0001.pdf?st=2018-08-17T10%3A55%3A38Z%26se=2018-08-18T10%3A55%3A38Z%26sp=r%26sv=2018-03-28%26sr=b%26sig=FTRoVgV7MRz5d5gTgrEs6D0QSy3268BqscZX1LHbJYQ%3D&language=English&exportformat=pdfSearchable&description=blah&imageSource=scanner
Next step: convert XML body into JSON...
Update 1
I have updated (17/08/2018) the replace with value from %2526 to %26. I was clearly getting my knickers in a twist. Must have been trying to double-escape, which isn't needed.
Although Microsoft seem to partially percent-encode the SAS token, I note they percent-encode = with %3D, however, the Abbyy API doesn't seem to care about =. (Testing from Postman).
Update 2
Not sure why Update 1 did work. It could be because I set the access policy to blob (anonymous read access for blobs only), and setting it back to private hadn't taken effect, or it might be the wrong content-type. Anyway, it worked and then it didn't. Well, it was replacing the & with %26 without issue, and I tried escaping the = too, but the endpoint didn't like it, testing via Postman and Logic App.
My trigger is actually a C# BlobTrigger* Azure Function App, and I have written code to generate the SAS token, so I used dotnet's Uri.EscapeDataString() method:
string fullUrl = cloudBlobContainer.Uri + "/" + blobName + sasToken;
string escapedUri = Uri.EscapeDataString(fullUrl);
log.LogInformation($"Full URL: {fullUrl}");
log.LogInformation($"Escaped URL: {escapedUri}");
return escapedUri;
Update 3
Just seen this line, created by the Logic App designer:
"path": "/datasets/#{encodeURIComponent(encodeURIComponent('https://someaccount.sharepoint.com/sites/eps'))}/tables//items//attachments",
Looks like encodeURIComponent() might be a function to do the same thing as Uri.EscapedDataString and would replace replace() function. I haven't tested it yet.
*the reason I am using a function app for the trigger is down to cost. Although there is a Logic App trigger that runs when a new blob is detected, it has to run to a schedule. My plan is consumption, and I have read that MS charge when a Logic App runs, regardless of whether it does anything or not. IMHO, it is inefficient to have a task triggering every 5 seconds, when 90% of the time there isn't anything for it to do. The function app is better suited to my requirements, although there is apparently a ~10 minute "warm-up" period, if the app has gone to sleep. I can live with that.
My requirement is to clear all activities on a notification feed.
Based on this stackoverflow question I understand that there is an undocumented REST API to delete a feed and the dashboard truncate feed functionality uses it.
I tried to replicate the call with the same parameters as dashboard:
DELETE /api/v1.0/feed/notification/f8fa1d12-594a-4b2b-ac58-23c912d1335a/?api_key=...&location=unspecified
Host: api.getstream.io
Authorization: notificationf8fa1d12-xxxx-xxxx-xxxx-23c912d1335a writetoken
stream-auth-type: simple
X-Stream-Client: stream-javascript-client-browser-unknown
Cache-Control: no-cache
Tried to use the same but am getting this error message:
{
"code": null,
"detail": "url signature missing or invalid",
"duration": "6ms",
"exception": "AuthenticationFailed",
"status_code": 403
}
Is this the right way to use this API?
I am using this from Java code and believe that the Java client doesn't have this functionality built in.
There's two ways to do this. You can do it manually from the explorer on the dashboard. Search for the feed, select an activity and press the truncate feed button. This is the easiest way to do this if manually doing this is sufficient.
It's also possible like you found to use the delete API endpoint to do it programmatically. This endpoint is not built in to most clients, including the Java client. The URL and HTTP verb that you used should indeed work.
From what I can tell from your headers and the response it seems like you are having an issue with supplying a correct signature. The easiest way to do this correctly is to use the built in methods in the library you're using to generate them. I'm not an expert in the Java library, but it seems like these methods are inside the StreamRepoUtils class.
I am working with a form system very similar to WUFOO that allows me to send data to an external website using WebHooks.
I have been able to connect my form to my ASANA system through Zapier but I cannot seem to get the API system to operate correctly. Can someone please advise or assist me on what I am doing incorrectly here?
In the screenshot note the following:
- Web URL functions for any web URL (https or http)
- HTTP method has POST, PUT, or GET options
- Data format allows me to input virtually anything so I can match up form fields with any necessary names for ASANA.
I simply cannot get the system to connect to ASANA. Please help me.
Screen shot of WebHook Options
I don't have access to your exact form builder but assuming it does what it says it is doing you can try the following. I'll use creating a task as an example.
Create a personal access token in Asana. To do this log in to Asana, click the icon in the top right corner and open "My profile settings". Go to the apps tab and create a personal access token. You will only ever see this token once so create a new one if you lose it. Also retrieve your workspace id, you can get it by opening app.asana.com/api/1.0/workspaces while logged in.
Now back to your form. For the website url place the specific endpoint you want to hit at Asana. For example, lets create a new task:
https://app.asana.com/api/1.0/tasks
Under the HTTP Method you want to select POST
Under the HTTP Headers you want to specify something like (replace 0/1234abcd with your access token):
{
"Authorization": "Bearer 0/1234abcd",
"Content-Type": "application/json"
}
You can use Send Raw Data and specify something like the following in the raw data section (replace 1234 with your workspace id):
{
"data": {
"workspace": 1234,
"name": "The name of the task"
}
}
You can of course add other fields- please see the API reference for more information:
https://asana.com/developers/api-reference/tasks
Let me know if that works for you.