GitHub GraphQL API doesn't return pull requests from user with private activity settings - github-api

I have a GitHub app that is authorized to access data from my workplace's private repository. I use the GitHub GraphQL API to search for each user's recent pull requests.
The pull request query works great except in the case of one user who has made their activity private.
Here's a basic version of the query:
query PRs($searchQuery: String!) {
search(query: $searchQuery, type: ISSUE, last: 100) {
issueCount
}
}
And here's the search query:
{
"searchQuery": "author:<user_login> type:pr merged:2022-09-25..2022-10-30"
}
I can get correct results from this search query with every other user in the org via GraphQL. I can see correct results for this user when I enter that query into the Pull Request repo search bar in the GH UI.
I can't find any documentation on GitHub's site that says they won't return activity via the GraphQL API. Can anyone confirm that's the case?
It seems weird that GitHub would interpret "private activity" as meaning that your own company can't retrieve it.

Related

Not able to download attachment from Azure Devops rest API using Postman

I am using Postman to hit azure devops Rest API for downloading the attachments.(fig)
Even after filling proper header, params it is showing { "count": 1, "value": { "Message": "The request is invalid." } }.
I am tried all most all the technique mention on stack overflow but none of them is working.
My goal is to download attachment from devops workitem.
I suppose you used the Work Item ID in the request URL, it is not correct, it should be the Attachment ID.
To get the Attachment ID, you need to use the REST API to get it first.
GET https://dev.azure.com/orgname/proname/_apis/wit/workitems/<Work Item ID>?$expand=all&api-version=6.0
Copy the Attachment ID above, then use it in the API below, it works for me.

How to get team avtar from DevOps api

I have tried to get team details using DevOps API, And I can get it but unable to get team Avtar/image, In response there is only text information, no descriptor available
I am using this way to get it..
https://learn.microsoft.com/en-us/rest/api/azure/devops/core/teams/get?view=azure-devops-rest-6.0
Can you please guide me how can I get team Avtar/image ???
How to get team avtar from DevOps api
In the security of Azure Devops, subjectDescriptor is user's SID. It used as identification when operating some security control. This parameter can uniquely identify the same graph subject across both Accounts and Organizations.
To get it, just use the following API:
GET https://vssps.dev.azure.com/{org name}/_apis/graph/users?api-version=5.1-preview.1
From its response body, you can get the descriptor value of corresponding user.
Next, you can pass the corresponding descriptor value as subjectDescriptor into REST API Avatars - Get:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/Subjects/{subjectDescriptor}/avatars?api-version=6.0-preview.1
In addition, the return result of above REST API is content of the image, in order to get the image of the avatar, we need provide the parameter format=png:
Update:
this api for user avtar... i want to get project avtar
To get the project avtar, we need to get the subjectDescriptor of the project. We could use the REST API:
https://dev.azure.com/{organization}/_apis/graph/descriptors/{Teams Id}?api-version=5.0-preview.1
To get the Teams Id, we could use the Teams - Get All Teams:
GET https://dev.azure.com/{organization}/_apis/teams?api-version=5.1-preview.1
Then get the Id of the descriptor for the teams project:
Now, we could get the project avtar:
Use Subject Query from Azure DevOps API Graph
Ref: https://learn.microsoft.com/en-us/rest/api/azure/devops/graph/subject%20query/query?view=azure-devops-rest-6.0
Define the body like this:
{
"query": "Your Group Name",
"subjectKind": [ "Group" ]
}
The descriptor is at the end of each item in a result.
Then use it in belov request to get avatar
https://dev.azure.com/(Organization)/_apis/GraphProfile/MemberAvatars/(descriptor)

how to pass and access path parameters in aws api gateway

I am new in web development and trying to learn AWS.
I have made a lambda function for listing.
What I am doing here is I am showing listing, if I get counteId in params(URL) then it shows only data of that counter id else it shows all data.
My lambda function was working fine. But I am having a problem while API integration.
this is how I am accessing pathparameters which are in the event
this is how I am configuring event
and this is my query and response
then I create an API gateway for it.
this is what I did while creating Resource
/{proxy+} - ANY - Setup
I want to get only data of counterId 1, but I am getting whole data.
response
My HTTPmethod is "ANY" and I choose lambda proxy integration in request integration.
I don't know how to send path parameters. Kindly help me.
You have to edit 'Mapping Template' in 'Integration Request' of you method properties in API Gateway.
You could find how to map it in API Gateway Mapping Template Reference article, in the 'Accessing the $input Variable' section.
Your template has to look like next:
{
"name" : "$input.params('name')",
"body" : $input.json('$')
}
Check out more details in my answer to the similar question.

Google Sheets v4 API calls using Node.js and the result is inconsistent

I'm trying to extract a short data from Google Sheet, the flow is as follow;
Authorizing the user (access type: offline)
Storing/caching the token per the oAuth2 flow.
Loading the cached token and use it to extract the data.
But once I uploaded on the server, the returned result become inconsistent.
I don't know what causing it because most of the time it returns the right data, and it works perfectly on my local.
Error Message;
Google sheet API read: Error: The request is missing a valid API key.
Server Information: Google App Engine, trial version;
runtime: nodejs
env: flex
The node.js code is below;
getUser(id) {
this.sheets.spreadsheets.values.get({
auth: this.oauth2Client,
spreadsheetId: id,
range: 'Sheet1!A1:E'
}, (err, response) => {
if(err) {
this.reject({
status: 0,
message: "Google sheet API read: " + err
});
return;
}
// The rest is omitted.
})
}
You can try the test request here (I haven't added any security measure for debugging purposes);
https://deep-contact-179901.appspot.com/v1/google/users
Based from this thread, all Google APIs require that you create a project on Google Developer Console and identify yourself and your application, even to access public data. Go to Google Developer Console and create a public api key. Remember to activate the Google Sheets API. Then just add key=[YourKey] as a parameter on your request.
Google sheet API read: Error: The request is missing a valid API key.
Means that you have not identified yourself to Google. In 2015 Google Start to require that we identify ourselves you cant just use a Google API without telling google who you are. You do that by creating a project on Google developer console. Create an API key and use that API key in all of your requests. This only works with Public data.
Note: With private user data you would need to use OAuth and use either access_token=your token or set the header
An access token is not the same as a API Key.
Hope this helps!

Get teams where the user is member, using Bitbucket API

How can I get a JSON object with teams (organizations) where the user is member?
I am searching in documentation and in Bitbucket REST API Console.
Basically I need the correspondent for orgs.getFromUser function from Github API where I pass the username after authenticating.
I think you're looking for this endpoint.
You provide the accountname and authenticate for it, and GET /1.0/groups/:accountname/. It will return a list of objects displayed on the documentation page.
Use the "User Endpoint" for API 1.0
https://confluence.atlassian.com/display/BITBUCKET/user+Endpoint
The call your looking for is: https://bitbucket.org/api/1.0/user/privileges
You need to call this with user authenticated:
curl -u "USER_NAME:USER_PASSWORD" https://bitbucket.org/api/1.0/user/privileges
This will return a list of teams:
{u'teams': {u'team1': u'admin', u'team2': u'admin'}}

Resources