@@ -79,16 +79,16 @@ jobs:
|
||||
issues: write {% endif %}
|
||||
steps:
|
||||
- name: Create issue using REST API
|
||||
run: {% raw %}|
|
||||
run: |
|
||||
curl --request POST \
|
||||
--url https://api.github.com/repos/${{ github.repository }}/issues \
|
||||
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
|
||||
--url {% data variables.product.api_url_code %}/repos/${% raw %}{{ github.repository }}{% endraw %}/issues \
|
||||
--header 'authorization: Bearer ${% raw %}{{ secrets.GITHUB_TOKEN }}{% endraw %}' \
|
||||
--header 'content-type: application/json' \
|
||||
--data '{
|
||||
"title": "Automated issue for commit: ${{ github.sha }}",
|
||||
"body": "This issue was automatically created by the GitHub Action workflow **${{ github.workflow }}**. \n\n The commit hash was: _${{ github.sha }}_."
|
||||
"title": "Automated issue for commit: ${% raw %}{{ github.sha }}{% endraw %}",
|
||||
"body": "This issue was automatically created by the GitHub Action workflow **${% raw %}{{ github.workflow }}{% endraw %}**. \n\n The commit hash was: _${% raw %}{{ github.sha }}{% endraw %}_."
|
||||
}' \
|
||||
--fail{% endraw %}
|
||||
--fail
|
||||
```
|
||||
|
||||
## Permissions for the `GITHUB_TOKEN`
|
||||
|
||||
@@ -84,7 +84,7 @@ You must have administrative access on your IdP to configure the application for
|
||||
|
||||
| Value | Other names | Description | Example |
|
||||
| :- | :- | :- | :- |
|
||||
| URL | Tenant URL | URL to the SCIM provisioning API for your enterprise on {% data variables.product.prodname_ghe_managed %} | <pre>https://api.<em>YOUR-GITHUB-AE-HOSTNAME</em>/scim/v2</pre> |
|
||||
| URL | Tenant URL | URL to the SCIM provisioning API for your enterprise on {% data variables.product.prodname_ghe_managed %} | <nobr><code>{% data variables.product.api_url_pre %}</nobr></code> |
|
||||
| Shared secret | Personal access token, secret token | Token for application on your IdP to perform provisioning tasks on behalf of an enterprise owner | Personal access token you created in step 1 |
|
||||
|
||||
{% endif %}
|
||||
|
||||
@@ -426,7 +426,7 @@ Here are a few common problems and some suggested solutions. If you run into any
|
||||
|
||||
* **Q:** I'm getting an `Octokit::NotFound` 404 error in my debug output:
|
||||
```
|
||||
2018-12-06 15:00:56 - Octokit::NotFound - POST https://api.github.com/app/installations/500991/access_tokens: 404 - Not Found // See: /v3/apps/#create-a-new-installation-token:
|
||||
2018-12-06 15:00:56 - Octokit::NotFound - POST {% data variables.product.api_url_code %}/app/installations/500991/access_tokens: 404 - Not Found // See: /v3/apps/#create-a-new-installation-token:
|
||||
```
|
||||
|
||||
**A:** Ensure the variables in your `.env` file are correct. Make sure that you have not set identical variables in any other environment variable files like `bash_profile`. You can check the environment variables your app is using by adding `puts` statements to your app code and re-running the code. For example, to ensure you have the correct private key set, you could add `puts PRIVATE_KEY` to your app code:
|
||||
|
||||
@@ -66,16 +66,16 @@ The content attachment flow shows you the relationship between the URL in the is
|
||||
|
||||
The `body` parameter can contain markdown:
|
||||
|
||||
```shell
|
||||
curl -X POST \
|
||||
https://api.github.com/repos/Codertocat/Hello-World/content_references/17/attachments \
|
||||
-H 'Accept: application/vnd.github.corsair-preview+json' \
|
||||
-H 'Authorization: Bearer $INSTALLATION_TOKEN' \
|
||||
-d '{
|
||||
"title": "[A-1234] Error found in core/models.py file",
|
||||
"body": "You have used an email that already exists for the user_email_uniq field.\n ## DETAILS:\n\nThe (email)=(Octocat@github.com) already exists.\n\n The error was found in core/models.py in get_or_create_user at line 62.\n\n self.save()"
|
||||
}'
|
||||
```
|
||||
```shell
|
||||
curl -X POST \
|
||||
{% data variables.product.api_url_code %}/repos/Codertocat/Hello-World/content_references/17/attachments \
|
||||
-H 'Accept: application/vnd.github.corsair-preview+json' \
|
||||
-H 'Authorization: Bearer $INSTALLATION_TOKEN' \
|
||||
-d '{
|
||||
"title": "[A-1234] Error found in core/models.py file",
|
||||
"body": "You have used an email that already exists for the user_email_uniq field.\n ## DETAILS:\n\nThe (email)=(Octocat@github.com) already exists.\n\n The error was found in core/models.py in get_or_create_user at line 62.\n\n self.save()"
|
||||
}'
|
||||
```
|
||||
|
||||
For more information about creating an installation token, see "[Authenticating as a GitHub App](/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation)."
|
||||
|
||||
@@ -111,7 +111,7 @@ mutation {
|
||||
Example cURL:
|
||||
|
||||
```shell
|
||||
curl -X "POST" "https://api.github.com/graphql" \
|
||||
curl -X "POST" "{% data variables.product.api_url_code %}/graphql" \
|
||||
-H 'Authorization: Bearer $INSTALLATION_TOKEN' \
|
||||
-H 'Accept: application/vnd.github.corsair-preview+json' \
|
||||
-H 'Content-Type: application/json; charset=utf-8' \
|
||||
|
||||
@@ -13,7 +13,9 @@ topics:
|
||||
---
|
||||
|
||||
|
||||
Let's walk through core API concepts as we tackle some everyday use cases.
|
||||
Let's walk through core API concepts as we tackle some everyday use cases.
|
||||
|
||||
{% data reusables.rest-api.dotcom-only-guide-note %}
|
||||
|
||||
## Overview
|
||||
|
||||
|
||||
@@ -12,16 +12,16 @@ topics:
|
||||
- API
|
||||
---
|
||||
|
||||
|
||||
|
||||
The {% data variables.product.product_name %} API provides a vast wealth of information for developers to consume.
|
||||
Most of the time, you might even find that you're asking for _too much_ information,
|
||||
and in order to keep our servers happy, the API will automatically [paginate the requested items][pagination].
|
||||
|
||||
In this guide, we'll make some calls to the {% data variables.product.product_name %} Search API, and iterate over
|
||||
In this guide, we'll make some calls to the Search API, and iterate over
|
||||
the results using pagination. You can find the complete source code for this project
|
||||
in the [platform-samples][platform samples] repository.
|
||||
|
||||
{% data reusables.rest-api.dotcom-only-guide-note %}
|
||||
|
||||
## Basics of Pagination
|
||||
|
||||
To start with, it's important to know a few facts about receiving paginated items:
|
||||
@@ -40,7 +40,7 @@ of an API call. For example, let's make a curl request to the search API, to fin
|
||||
out how many times Mozilla projects use the phrase `addClass`:
|
||||
|
||||
```shell
|
||||
$ curl -I "{% data variables.product.api_url_pre %}/search/code?q=addClass+user:mozilla"
|
||||
$ curl -I "https://api.github.com/search/code?q=addClass+user:mozilla"
|
||||
```
|
||||
|
||||
The `-I` parameter indicates that we only care about the headers, not the actual
|
||||
@@ -66,7 +66,7 @@ parameter. By default, `page` always starts at `1`. Let's jump ahead to page 14
|
||||
and see what happens:
|
||||
|
||||
```shell
|
||||
$ curl -I "{% data variables.product.api_url_pre %}/search/code?q=addClass+user:mozilla&page=14"
|
||||
$ curl -I "https://api.github.com/search/code?q=addClass+user:mozilla&page=14"
|
||||
```
|
||||
|
||||
Here's the link header once more:
|
||||
@@ -88,7 +88,7 @@ By passing the `per_page` parameter, you can specify how many items you want
|
||||
each page to return, up to 100 items. Let's try asking for 50 items about `addClass`:
|
||||
|
||||
```shell
|
||||
$ curl -I "{% data variables.product.api_url_pre %}/search/code?q=addClass+user:mozilla&per_page=50"
|
||||
$ curl -I "https://api.github.com/search/code?q=addClass+user:mozilla&per_page=50"
|
||||
```
|
||||
|
||||
Notice what it does to the header response:
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
1. Under "{% data variables.product.prodname_dotcom %} API URL", type {% if currentVersion == "free-pro-team@latest" %}https://api.github.com {% else %}the URL you use to access {% data variables.product.prodname_enterprise %}{% endif %}.
|
||||
1. Under "{% data variables.product.prodname_dotcom %} API URL", type {% if currentVersion == "free-pro-team@latest" %}https://api.github.com{% else %}the URL you use to access {% data variables.product.product_name %}{% endif %}.
|
||||

|
||||
|
||||
13
data/reusables/rest-api/dotcom-only-guide-note.md
Normal file
13
data/reusables/rest-api/dotcom-only-guide-note.md
Normal file
@@ -0,0 +1,13 @@
|
||||
{% if currentVersion != "free-pro-team@latest" %}
|
||||
|
||||
{% note %}
|
||||
|
||||
**Note**: The following guide uses the REST API for {% data variables.product.prodname_dotcom_the_website %}.
|
||||
|
||||
- Use <code>{% data variables.product.api_url_pre %}</code> to access the API for {% data variables.product.product_name %}.
|
||||
|
||||
- The guide specifies usernames and repositories that may not exist on {% data variables.product.product_location %}. You may need to use different names to see similar output.
|
||||
|
||||
{% endnote %}
|
||||
|
||||
{% endif %}
|
||||
@@ -188,7 +188,7 @@ doc_url_pre: >-
|
||||
{% if currentVersion == "free-pro-team@latest" %}https://docs.github.com/rest{% elsif enterpriseServerVersions contains currentVersion %}https://docs.github.com/enterprise/{{ currentVersion | version_num }}/rest{% elsif currentVersion == "github-ae@latest" %}https://docs.github.com/github-ae@latest/rest{% endif %}
|
||||
# Use this inside command-line code blocks
|
||||
api_url_pre: >-
|
||||
{% if currentVersion == "free-pro-team@latest" %}https://api.github.com{% elsif enterpriseServerVersions contains currentVersion %}http(s)://<em>[hostname]</em>/api/v3{% elsif currentVersion == "github-ae@latest" %}https://api.<em>[hostname]</em>{% endif %}
|
||||
{% if currentVersion == "free-pro-team@latest" %}https://api.github.com{% elsif enterpriseServerVersions contains currentVersion %}http(s)://<em>[hostname]</em>/api/v3{% elsif currentVersion == "github-ae@latest" %}https://<em>[hostname]</em>/api/v3{% endif %}
|
||||
# Use this inside command-line code blocks
|
||||
# Enterprise OAuth paths that don't include "/graphql" or "/api/v3"
|
||||
oauth_host_code: >-
|
||||
@@ -197,7 +197,7 @@ device_authorization_url: >-
|
||||
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.21" or currentVersion == "github-ae@latest" %}[`https://github.com/login/device`](https://github.com/login/device){% else %}`http(s)://[hostname]/login/device`{% endif %}
|
||||
# Use this all other code blocks
|
||||
api_url_code: >-
|
||||
{% if currentVersion == "free-pro-team@latest" %}https://api.github.com{% elsif enterpriseServerVersions contains currentVersion %}http(s)://[hostname]/api/v3{% elsif currentVersion == "github-ae@latest" %}https://api.[hostname]{% endif %}
|
||||
{% if currentVersion == "free-pro-team@latest" %}https://api.github.com{% elsif enterpriseServerVersions contains currentVersion %}http(s)://[hostname]/api/v3{% elsif currentVersion == "github-ae@latest" %}https://[hostname]/api/v3{% endif %}
|
||||
# Use this inside command-line code blocks
|
||||
graphql_url_pre: >-
|
||||
{% if currentVersion == "free-pro-team@latest" %}https://api.github.com/graphql{% elsif enterpriseServerVersions contains currentVersion %}http(s)://<em>[hostname]</em>/api/graphql{% elsif currentVersion == "github-ae@latest" %}https://api.<em>[hostname]</em>/graphql{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user