Moving issues from excel to github organization - github

I am trying to move a bunch of issues from excel to GitHub issues.
The problem I am encountering is that I can not figure out how to use get an access token for an organization in order to automate pushing the issues to GitHub.
I tried to make an OAuth token for that organization but I keep getting an bad credential error.

Make sure your OAuth token has a "repo" scopr.
Then try creating a new issue (as in this gist)
curl -X "POST" "https://api.github.com/repos/rickcogley/REPONAME/issues?state=all" \
-H "Cookie: logged_in=no" \
-H "Authorization: token THEd13GITHUBfb87TOKENa4FROM5eSETTINGS" \
-H "Content-Type: text/plain; charset=utf-8" \
-d $'{
"title": "A workflow alerts Operator who performs a process",
"body": "TBD",
"milestone": 5,
"assignees": [
"RickCogley",
"NathanielPhillips"
],
"labels": [
"story",
"#2",
"enhancement",
"production"
]
}'

Related

How to attach docs and import issue at the same time using GitHub API?

I need to import all bug reports and attachments from my internal system to GitHub Issues.
What GitHub API parameter should I use to attach a document in my curl command?
curl -X "POST" \
-H "Accept: application/vnd.github+json" \
-H "Accept: application/vnd.github.VERSION.html" \
-H "Authorization: token <token>" \
https://api.github.com/repos/BT23/demo-repo/issues \
-d '{
"title":"Create an issue in HTML format",
"body":"<H1>Testing HTML tags</H1><P>Does it work?</P>",
"assignee": "BT23",
"milestone": 1,
"labels":["bug", "functional"]
}'
Thanks
I do not see the word file anywhere in Issues API.
And this thread confirms you cannot attach a file during Issue Creation.
Adding a file to issue or pull request seems to be done manually through drag & drop only.

GitHub actions repository_dispatch event POST request not working due to organisation repository

I am trying to trigger a GitHub action workflow, which is in my organisations repository and I am the owner of the organsisation
I am trying to trigger using below POST request
curl -H "Accept: application/vnd.github+json" -H "Authorization: token " --request POST --data '{"event_type": "do-something"}' https://api.github.com/repos/USER/REPO/dispatches
But I am getting below message
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/reference/repos#create-a-repository-dispatch-event"
}
my workflow
name: Node.js CI
on:
repository_dispatch:
schedule:
- cron: '5 12 * * 0'
jobs:
build:
runs-on: ubuntu-latest
I think as it not in my account instead it is in organisation account, that is why it might be giving this error.
Any work-around will be helpful.
Generate a token from Github Setting Panel with appropriate privileges and use the following URL
curl -X POST -u <githubusername>:<token> -H "Content-Type: application/json" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/<organization>/<repository_name>/dispatches" -d #test.json
Where test.json contains your json data.
As per the docs
This endpoint here requires write access to the repository by providing either:
Personal access tokens with repo scope. For more information, see "Creating a personal access token for the command line" in the GitHub Help documentation.
GitHub Apps with both metadata:read and contents:read&write permissions.
token - A repo scoped GitHub Personal Access Token.
Validate that your token has full scope of repo.
curl 'https://api.github.com/repos/USER/REPO/dispatches' --request POST \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Content-Type: application/javascript' \
-H 'Authorization: Bearer token' \
--data-raw '{
"event_type": "do-something",
"client_payload": { "text": "my custom text here" }
}'

Creating merchant application using Identity API for Paypal

I am trying to create an application for merchants using the below API.
https://developer.paypal.com/docs/api/identity/v1
Not able to create that passed the required parameters. I have payer_id id which I am getting in the response of /v1/identity/oauth2/userinfo. I get that special permissions from Paypal.
Here is my request body
curl -v -X POST https://api.paypal.com/v1/identity/applications \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ------------------------" \
-d '{
"application_type": "not cleared what need to add here",
"redirect_uris": [
"return url"
],
"client_name": "Avtar Singh",
"contacts": [
"-------"
],
"payer_id": "-------------",
"migrated_app": "not cleared what need to add here"
}'

How to include fiware-service and fiware-servicePath headers in an Orion Context Broker registration to a Context Provider?

We are researching about the Orion Context Broker technology using local Docker containers and trying to integrate the local Context Broker with an external Context Provider.
Specifically, we are trying to retrieve data from this Context provider:
https://streams.lab.fiware.org/v2/entities?type=AirQualityObserved&options=keyValues
Using the headers:
fiware-service: environment
fiware-servicePath: /Madrid
Concretely, our objective is to achieve a registration from our Context Broker to this node of the provider, in order to get some attributes that we don't have in local (in that example, the attribute is called "NO").
The request we are sending for the registration is the following one:
curl -iX POST \
'http://localhost:1026/v2/registrations' \
-H 'Content-Type: application/json' \
-d '{
"description": "Air Quality Madrid",
"dataProvided": {
"entities": [
{
"id": "Madrid-AirQualityObserved-28079059-latest",
"type": "AirQualityObserved"
}
],
"attrs": [
"NO"
]
},
"provider": {
"http": {
"url": "https://streams.lab.fiware.org"
}
}
}'
Additionally, we have created a local entity with the same id as in the request: Madrid-AirQualityObserved-28079059-latest
After that information, the question is:
Is it possible to include the specific fiware-service and fiware-servicePath headers into the registration request? What is the way to include them?
Thanks in advance.
EDIT:
I've been doing more tests with the following commands:
For registering to the context provider, using the specific headers for the desired service. For now, the local entity is not created in the local context broker.
curl -iX POST \
'http://localhost:1026/v2/registrations' \
-H 'Content-Type: application/json' \
-H 'fiware-service: environment' \
-H 'fiware-servicepath: /Madrid' \
-d '{
"description": "Air Quality Madrid",
"dataProvided": {
"entities": [
{
"id": "Madrid-AirQualityObserved-28079059-latest",
"type": "AirQualityObserved"
}
],
"attrs": [
"NO"
]
},
"provider": {
"http": {
"url": "https://streams.lab.fiware.org"
}
}
}'
Then, I've check if the registration has been correctly registered:
curl -X GET http://localhost:1026/v2/registrations \
-H 'fiware-service: environment'
-H 'fiware-servicepath: /Madrid'
Finally, I've tried to retrieve the entity from the provider:
curl -X GET http://localhost:1026/v2/entities/Madrid-AirQualityObserved-28079059-latest \
-H 'fiware-service: environment' \
-H 'fiware-servicepath: /Madrid'
But the response indicates that there is not any entity for that request. Because of that, I've created the entity in the local context broker, excluding the field that I'm trying to obtain from the provider "NO".
curl -iX POST \
'http://localhost:1026/v2/entities' \
-H 'Content-Type: application/json' \
-H 'fiware-service: environment' \
-H 'fiware-servicepath: /Madrid' \
-d '
{
"id": "Madrid-AirQualityObserved-28079059-latest",
"type": "AirQualityObserved"
}'
However, if I consult the entity with the ID Madrid-AirQualityObserved-28079059-latest, I'm receiving the local data, and the field "NO" is not being retrieved from the provider. That is the response (missing the NO field):
{
"id": "Madrid-AirQualityObserved-28079059-latest",
"type": "AirQualityObserved"
}
What I am doing wrong?
Yes, it's possible.
They are included as regular headers. For instance, if you are using curl, it would be something like -H 'fiware-service: environment' -H 'fiware-servicepath: /Madrid'.
EDIT:
Looking to the query request you are using:
curl -X GET http://localhost:1026/v2/entities/Madrid-AirQualityObserved-28079059-latest \
-H 'fiware-service: environment' \
-H 'fiware-servicepath: /Madrid'
I see are not incluing the entity type in the query, contrary to the recomendation in the context providers and request forwarding documentantation:
On forwarding, any type of entity in the NGSIv2 update/query matches registrations without entity type. However, the opposite doesn't work, so if you have registrations with types, then you must use ?type in NGSIv2 update/query in order to obtain a match. Otherwise you may encounter problems, like the one described in this post at StackOverflow.
So maybe you should use:
curl -X GET http://localhost:1026/v2/entities/Madrid-AirQualityObserved-28079059-latest?type=AirQualityObserved \
-H 'fiware-service: environment' \
-H 'fiware-servicepath: /Madrid'

get build status through github api

The GitHub API provides a lot of functionality, but is there a way to retrieve the build status for a commit? The GitHub UI provides information from the CI system we have configured, but I can't see this information exposed through the API?
You can access the status for a particular ref
GET https://api.github.com/repos/:owner/:repo/commits/:ref/statuses
For the value of :ref, you can use a SHA, a branch name, or a tag name.
It doesn't provide status directly, but offers you to create a status
That means the CI can have a final build step which publishes the status to GitHub repo that way.
POST /repos/:owner/:repo/statuses/:sha
For example:
{
"state": "success",
"target_url": "https://example.com/build/status",
"description": "The build succeeded!",
"context": "continuous-integration/jenkins"
}
(and that, for a given SHA1)
See for instance "Github Commit Status API with Bamboo from Atlassian", where:
${bamboo.buildResultsUrl} is the GitHub commit SHA1:
<xxx> is a placeholder value, which can be replaced by a value, or a variable ${var} as shown here.
Add those to your plan as Script.
complete.sh:
# specs and cukes results are stored in JUnit format under test-reports
if (grep 'failures="[^0]"' test-reports/* || \
grep 'errors="[^0]"' test-reports/*); then
curl -H "Authorization: token <MY_TOKEN>" --request POST \
--data '{"state": "failure", "description": "Failed!", \
"target_url": "${bamboo.buildResultsUrl}"}' \
https://api.github.com/repos/<USER>/<REPO>/statuses/${bamboo.repository.revision.number} > /dev/null
else
curl -H "Authorization: token <MY_TOKEN>" --request POST \
--data '{"state": "success", "description": "Success!", \
"target_url": "${bamboo.buildResultsUrl}"}' \
https://api.github.com/repos/<USER>/<REPO>/statuses \
/${bamboo.repository.revision.number} > /dev/null
fi
pending.sh:
curl -H "Authorization: token <MY_TOKEN>" --request POST \
--data '{"state": "pending", "description": "Build is running", \
"target_url": "${bamboo.buildResultsUrl}"}' \
https://api.github.com/repos/<USER>/<REPO>/statuses/${bamboo.repository.revision.number} > /dev/null