Follow Azure acklog item via HTTP Request - http

Is there a way to follow an Azure Backlog item or to add it into the list of the items I'm following via HTTP Request?
Here is the way I get all work items I'm following:
POST https://dev.azure.com/companyName/projectName/_apis/wit/wiql?api-version=5.1&Authorization=Basic BASE64PATSTRING
Body:
{
"query": "Select [System.Id], [System.WorkItemType] From WorkItems Where [System.Id] IN(#Follows)"
}
Thanks in advance for your help.

We can follow the work item via REST API, a skeleton version looks like this:
API:
POST https://dev.azure.com/{org name} /_apis/notification/Subscriptions?api-version=5.1
Request body
{
"filter": {
"type": "Artifact",
"artifactType": "WorkItem",
"artifactId": "70"
}
}
Note: artifactId is work item ID
Result:

Related

Extract deep link from Firebase short dynamic link

I'm using Firebase REST APIs to create a short dynamic link on my backend. I'm writing tests (working in TypeScript) to check that functionality and I need to somehow programmatically extract the deep link nested inside the short dynamic link in order to check that I'm passing correct parameters to the mobile apps. Is it possible to do this?
Example request:
POST https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=api_key
Content-Type: application/json
{
"dynamicLinkInfo": {
"domainUriPrefix": "https://example.page.link",
"link": "https://www.example.com/data?param1=value1&param2=value2",
"androidInfo": {
"androidPackageName": "com.example.android"
},
"iosInfo": {
"iosBundleId": "com.example.ios"
}
}
}
Example response:
https://example.page.link/WXYZ
I'm gonna get the result https://example.page.link/WXYZ in my test and then I want to do some magic (request it in a special way and parse the response?) in order to get the deep link it wraps - https://www.example.com/data?param1=value1&param2=value2.

Using Request Headers in Query/Mutation

I am following Hasura basic tutorial on creating a todo app https://hasura.io/learn/graphql/hasura-advanced/introduction/ and want to extend it and have few additional operations, but don't seem to be able. Setup is as in the tutorial - you have Tasks table with title, description, authorId, isComplete, isPublic column. Table permissions are setup as in the tutorial, so a user can only select their own or public tasks. They can also update only their own tasks. Operations I want to add:
Query only public tasks that are NOT theirs (additionally, inverse also - only theirs without public ones).
Mutate public tasks to complete that are not theirs (update isComplete without having permissions to other columns).
I could create views for the first case, but it seems too much of an effort for such a simple logic. I think both cases could simply be done with access to Request Header (x-hasura-user-id) like so:
query PublicTasksOnly {
tasks(where: {isPublic: {_eq: true}, authorId: {_neq: x-hasura-user-id}}) {
description
isComplete
title
}
}
But it seems that this is not possible. Any ideas/suggestions how to achieve this?
To my knowledge I do not think it is possible to reference http headers in your graphql queries. Have you tried passing the userId as a variable to the query? Something like the following:
query PublicTasksOnly($userId: String!) {
tasks(where: {isPublic: {_eq: true}, authorId: {_neq: $userId}}) {
description
isComplete
title
}
}
I am not quite sure what you want to achieve but if your problem gets solved by adding this header x-hasura-user-id then I can help you out.
You can copy the graphql endpoint from hasura console and hit simple http request to that endpoint with query and it's variables in request body. Sharing sample code here using http library axios:
import axios from 'axios';
axios({
method: 'post',
url: 'https://your-hasura-project-url.hasura.app/v1/graphql',
headers: { 'x-hasura-user-id': '< Your user id >' },
data: {
query: `query PublicTasksOnly {
tasks(where: {isPublic: {_eq: true}}) {
description
isComplete
title
}
}`,
variables: { userId: 'abc-xyz' }
}
})
This should solve your issue.

Fetch company posts from linkedin API

I am trying to fetch the posts of the company from the api, I have already applied to the marketing development platform and it was approved. I already got the token with the scope: r_organization_social and I'm calling the /shares api:
https://api.linkedin.com/v2/shares?q=owners&owners=urn:li:organization:{company_ID}&sharesPerOwner=100&count=25&sharesPerOwner=10
But I'm getting the following response:
{
"paging": {
"start": 0,
"count": 25,
"links": [
{
"type": "application/json",
"rel": "next",
"href": "/v2/shares?count=25&owners=urn%3Ali%3Aorganization%3A{company_ID}&q=owners&sharesPerOwner=10&sharesPerOwner=100&start=0"
}
],
"total": 242
},
"elements": []
}
I tried to change the query params and it's still the same
This end-point worked for me:
https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A<ID_ORGANIZATION>)
See documentation: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api?tabs=http#sample-request-6
Disclaimer: I've no access to the linkedin API and couldn't test. But these are some things I noticed:
Your url contains two times the paramater sharesPerOwner, try removing one.
In the docs it's recommended to set the sharesPerOwner to 1000 and the count to 50. I'd also include the start paramater, just to make sure:
Maybe try something like this:
GET https://api.linkedin.com/v2/shares?q=owners&owners=urn:li:organization:{id}&sharesPerOwner=1000&count=50&start=0
From the api-docs(https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api?tabs=http#find-shares-by-owner): "Note that the pagination excludes UGC and Direct Sponsored Content (DSC) posts". Make sure that the owner you are testing contains posts.
If this doesn't work. Could you provide some information on how you are sending the request? Have you tried accessing other parts of the api?

Exist some way to pass custom parameter to short dynamic link on Firebase?

I know how to pass a custom parameter from a DynamicLink created in FireBase and get it on my app but the problem is that I can only make this work with the large link version, like this:
https://example.page.link/?link=https://example.com.br/?PARAMETER=VALUE&apn=com.example.br
The problem is that the link is too large, how can I send CUSTOM parameter with the short version from DynamicLink on Firebase?
You can probably get it to work if you send a request body instead of URL parameters. The REST docs explain how to:
{
"dynamicLinkInfo": {
"domainUriPrefix": string,
"link": string,
},
"suffix": {
"option": "SHORT" or "UNGUESSABLE"
}
}

Firestore Update a document field Using Rest API

Im trying to perform PATCH Opeartion in cloud firestore using REST API.
This is my Request body
`{
"fields": {
"name": {
"stringValue":"Dinesh"
}
}
}`
When i fire the request , All the existing fields inside the document are getting deleted and only the name field is getting updated. In the Documentation they have given the Document Mask. but i dont understand how it works , neither im able to find any samples for that. Somebody know how to update only one field inside the document without affecting other fields ?
Without a DocumentMask object, the patch method defaults to replacing the Firestore Document with the request body rather than updating the submitted fields and retaining omitted fields.
The DocumentMask is submitted as an updateMask parameter containing the fieldPaths to be patched. It took a while but thanks to this answer and a lot of attempts I figured out that each fieldPath property of the updateMask object needs to be individually included in the query string of the request url:
https://firestore.googleapis.com/v1beta1/projects/{projectId}/databases/{databaseId}/documents/{document_path}?updateMask.fieldPaths=status&updateMask.fieldPaths=title
Where status and title are two fields in the request body. Note that fields included in the request body are disregarded if they are omitted from the query string, remaining unchanged.
Here is another example giving this json structure from firestore
"fields": {
"eth0": {
"mapValue": {
"fields": {
"address": {
"stringValue": "172.0.0.1"
},
"port": {
"stringValue": "8080"
},
"endpoint": {
"stringValue": "10.0.5.24"
}
}
}
}
}
Then to update the endpoint field only
curl -sSLX PATCH \
-H "Authorization: Bearer {TOKEN}" \
-H "Content-type: application/json" \
-d "{
\"fields\": {
\"eth0\": {
\"mapValue\": {
\"fields\": {
\"endpoint\": {
\"stringValue\": \"10.10.2.24\"
}
}
}
}
}
}" \
"https://firestore.googleapis.com/v1/projects/{project-id}/databases/(default)/documents/{collection}/{document}?updateMask.fieldPaths=eth0.endpoint")
Your request body is ok. But you need to use the update mask.
From reading the documents I found that the DocumentMask is used to restrict a get or update operation on a document to a subset of its fields. So by adding 'name' to your field paths on the mask, it will only allow you to update that specific field and the others won't get deleted.
You can read more about it here.

Resources