How to get file content of repositories in Azure DevOps - azure-devops

could someone tell a way to get file contents through rest api in azure devops?
I tried in this way but it isnt getting proper results.
https://dev.azure.com/org/project/_apis/sourceProviders/Git/filecontents?serviceEndpointId=&repository=&commitOrBranch=main&path=/&api-version=6.0-preview.1

The URL I have posted above works..I had given wrong input for source provider. It should have been TfsGit.

It should be in this format https://dev.azure.com/{organization}/{project}/_apis/sourceProviders/{providerName}/filecontents?api-version=5.0-preview.1
Service endpoint should be TFGit as per the documentation here

Related

Fetch the data from Power BI related to username/emailId by whom Azure Pipeline was ran

"https://analytics.dev.azure.com/{organization}/{project}/_odata/v3.0-preview/PipelineRuns?"
Using this url I am able to fetch RunNumber, RunReason but unable to fetch RunBy which user.
You could get the user that requested the run using predefined variables.
$(Build.RequestedFor)
And additionally you can also use
echo $(Build.RequestedForEmail)
echo $(Build.RequestedForId)
https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#identity_values
There are some predefined variable for RunReason and BuildID as well.
$(Build.Reason)
$(Build.BuildId)
According to your description, I tried to get the odata feed "https://analytics.dev.azure.com/{organization}/{project}/_odata/v3.0-preview/PipelineRuns" in Power BI, currently there is no option to fetch who trigger the pipeline. And check the REST API is also without this.
You could use "Request a feature" on the left side of Developer Community to open a new suggestion ticket.
For more information about who trigger the pipeline, you could refer to this.

How to get version history of a file in folder in sharepoint using SharePoint REST API using c#?

I have a SharePoint library with a file in it. I need to get previous versions of the file who created it and when. What is the rest endpoint to fetch those details. I am new to SharePoint. Please help
You could use this rest endpoint to get previous versions of the file by the file id:
https://<server>/sites/<site>/_api/web/lists/getByTitle('Documents')/items(1)/versions
You could add filters at the end to get the information you need:
https://<server>/sites/<site>/_api/web/lists/getByTitle('Documents')/items(1)/versions?$select=VersionLabel,Created_x005f_x0020_x005f_By,Created
in order to get additional information from REST API request You need to use the $expand property. If You need information like who made the update please add '?$expand=CreatedBy' at the end of the request.. so for Your example it will be something like:
https:///sites//_api/web/GetFolderByServerRelativeUrl('Shared%20Documents/general')/files('SampleDocFile.docx')/versions?$expand=CreatedBy
that way You will have the user who modified the file in
content>properties>Title
other interesting data is:
updated>
content>properties>CheckInComment>
content>properties>VersionLabel>

MS VSTS Rest API's: Get List of Attachments for a given item

Using the Azure API's, I am able to get the content of an attachment using:
GET https://dev.azure.com/fabrikam/_apis/wit/attachments/{id}?api-version=4.1
This assumes you know the guid (id) of the attachment you wish to download.
What I am trying to do is for a given workItem ID, get a list of ALL attachments (including the ID). Anyone know what the easiest way to achieve this is?
I find this Azure API may be helpful for you.
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems?ids={ids}&api-version=4.1
For more details, you can refer to this doc.
Try $expand=Relations in the Api-Url
E.g. GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems?ids={ids}&$expand=Relations&api-version=4.1

Notification Templating with WebHooks default payload (Appveyor)

So currently I am in the process of setting up notifications, and what I had wanted to send in my message portion was the url for the artifact zip file that was created.
I took a look at the default payload (https://www.appveyor.com/docs/notifications/#webhook-payload-default) and was able to send {{jobs}} which gave me in the email this:
System.Collections.Generic.List`1[Appveyor.Models.BuildJobNotificationTemplateData]
I figured I could traverse this in my messaging template. However, when I tried to do that it kept erroring out with different methods that I’ve tried.
Some of them include :
{{jobs[0].artifacts[0].url}}
{{jobs.artifacts.url}}
{{eventData.jobs.artifacts.url}}
{{eventData.jobs[0].artifacts[0].url}}
Etc…
What would the proper syntax be to grab the first artifacts url using the templating engine?
This syntax will work (see mustache template to understand the syntax)
<p>Artifacts:</p>
<ul>
{{#jobs}}
{{#artifacts}}
<li>{{url}}</li>
{{/artifacts}}
{{/jobs}}
</ul>
But unfortunately it will return temporary Azure blob storage URL, which will expire in 60 minutes. Please watch https://github.com/appveyor/ci/issues/1646. For now to get permanent URL please use this workaround

How to Get Sharepoint data?

I have just started a Sharepoint, I would need items listed in Sharepoint 2013.
Please let me know is any rest service available to access data from sharepoint which I can store in my local db.
Please suggest me what are the best way to access data from it.
Thanks,
Laxmilal Menaria
In SharePoint 2013 the REST API Endpoints are different.
It's more like this:
/_api/lists/getByTitle('Custom List')/Items
You can use the REST interface.
http://msdn.microsoft.com/en-in/library/ff798339.aspx
For example:
http://localhost/_vti_bin/listdata.svc/Parts(3)
The preceding URL returns the Parts list item with an ID value of 3 as an Atom feed.