Description Usage Arguments Details Value Examples
This function can be used to make "GET", "POST", "PATCH", "PUT" or "DELETE" requests to the specified URL.
1 2 3 4 5 6 7 8 9 10 |
url |
(string) The address of the API endpoint. |
type |
(string) The type of HTTP request. Either "GET", "POST", "PATCH", "PUT" or "DELETE". |
payload |
(list, optional) The information to send to the API for
"POST", "PATCH", "PUT" or "DELETE" requests. Default: |
headers |
(character, optional) Headers to add to the request. Default:
|
accept |
(string, optional) The mime format to accept when making the
call. Default: |
token |
(string or Token, optional) An authorisation token to include
with the request. If |
proxy |
(character, optional) The proxy server to use to connect to the
github API. If |
... |
Ignored. |
The response is parsed from either JSON or plain text, depending on the format received. When no response is received an empty list returned by the function. Details of the response are recorded as attributes.
For "POST", "PATCH", "PUT" and "DELETE" requests a payload can be supplied. It is parsed into a JSON format before being sent to the URL.
If an error is returned from the API then an error is thrown by this function, detailing the URL, the HTTP status code and a message from the API, if there is one.
Finally, an authorisation token can be supplied if it is required.
A github
list object consisting of the response, parsed into a
list, with the attributes:
url: The URL the request was sent to
request: The type of HTTP request made
status: The HTTP status code returned
header: The HTTP header returned
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ## Not run:
# Create a tag
gh_request(
url = "https://api.github.com/repos/ChadGoymer/githapi/git/refs",
type = "POST",
payload = list(
ref = "test-tag",
sha = "a4b6545671455234757313a42738e44c10b0ef37"
)
)
# View a tag
gh_request(
url = "https://api.github.com/repos/ChadGoymer/githapi/git/test-tag",
type = "GET"
)
# Update a tag
gh_request(
url = "https://api.github.com/repos/ChadGoymer/githapi/git/test-tag",
type = "PATCH",
payload = list(sha = "a4b6545671455234757313a42738e44c10b0ef37")
)
# Delete a tag
gh_request(
url = "https://api.github.com/repos/ChadGoymer/githapi/git/test-tag",
type = "DELETE"
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.