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

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

Related

How to get file content of repositories in 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

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>

how to get all the Task in a Workitem in Json form by postman for TFS API

i am currently using TFS API who's link is
https://www.visualstudio.com/en-us/docs/integrate/api/wit/work-items#byids
currently in my project i want to accees the following workitem 61092 all the task
http://apactfs.cbre.com:8080/tfs/CBRE.APAC.Applications/MRI_SCRUM_GIT/_workitems?_a=edit&id=61092
for that i am using this link in postman GET
http://apactfs.cbre.com:8080/tfs/cbre.apac.applications/_apis/wit/workitems/61092?$expand=all&api-version=1.0
i am getting all the task related to it but not getting all the field such as number of hours in the task,user of the task which i wanted.
and in Postman i am hitting the id by this Link By GET
http://apactfs.cbre.com:8080/tfs/cbre.apac.applications/MRI_SCRUM_GIT/_workitems?_a=edit&id=61092&api-version=1.0
According to your screenshot, 61092 is a Product Backlog Item. The Rest API URL you use can only get the detailed information of the work item 61092 itself, it cannot get the detailed information about the work items that linked to 61092.
You have to use One-hop Query to get all the tasks related to it and then get the detailed data for each task returned. Refer to this link for details: Get Work Items.
$expand=all has already expand all fields, but it doesn't show the empty fields in response. If you type a value for the field you want to get, you will see it as expect in response.

Get Attachment from ServiceNow INC via Powershell

Im trying to download an attachment from a ServiceNow Change Request via Powershell. The attachment sys_id is different from the Change Request sys_id so I am not sure how to join them. The only things I can seem to find on the matter are in Java(?maybe?) and I do not know Java nor know how to bring Java into Powershell to retrieve the data. Any help would be greatly appreciated! Thank you.
To make a REST call via PowerShell, use "Invoke-RestMethod".
Example
You can also script it out. Here's the doc: https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.utility/invoke-restmethod
What you want to do to get the attachment, is use the attachment API: /api/now/attachment/[attachment record sys_id].
You can get this sys_id of any attachments associated with a given record, by performing this query on the sys_attachment table:
table_sys_id=[your record's sys_id here]
Once you've got the sys_id of the attachment(s) you're looking for, just plug them one-by-one, into the attachment API mentioned above.
Should be no problemo to script this all out in powershell. :-)

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.