New-GitHubRepositoryUploadReleaseAsset

SYNOPSIS

Upload a release asset

SYNTAX

__AllParameterSets

New-GitHubRepositoryUploadReleaseAsset [-Owner] <string> [-Repo] <string> [-ReleaseId] <long>
 -Name <string> -InFile <string> [-Label <string>] [-ContentType <string>] [-Accept <string>]
 [-WhatIf] [-Confirm]

ALIASES

This cmdlet has the following aliases,

  • Get-GHNewRepositoryUploadReleaseAsset

DESCRIPTION

The New-GitHubRepositoryUploadReleaseAsset cmdlet invokes the POST method of the /repos/{owner}/{repo}/releases/{release_id}/assets endpoint (Upload a release asset)

This endpoint makes use of a Hypermedia relation (https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#hypermedia) to determine which URL to access. The endpoint you call to upload release assets is specific to your release. Use the ‘upload_url’ returned in the response of the Create a release endpoint (https://docs.github.com/rest/releases/releases#create-a-release) to upload a release asset.

You need to use an HTTP client which supports SNI (http://en.wikipedia.org/wiki/Server_Name_Indication) to make calls to this endpoint.

Most libraries will set the required ‘Content-Length’ header automatically. Use the required ‘Content-Type’ header to provide the media type of the asset. For a list of media types, see Media Types (https://www.iana.org/assignments/media-types/media-types.xhtml). For example:

‘application/zip’

GitHub expects the asset data in its raw binary form, rather than JSON. You will send the raw binary content of the asset as the request body. Everything else about the endpoint is the same as the rest of the API. For example, you’ll still need to pass your authentication to be able to upload an asset.

When an upstream failure occurs, you will receive a ‘502 Bad Gateway’ status. This may leave an empty asset with a state of ‘starter’. It can be safely deleted.

Notes:

  • GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The “List release assets (https://docs.github.com/rest/releases/assets#list-release-assets)” endpoint lists the renamed filenames. For more information and help, contact GitHub Support (https://support.github.com/contact?tags=dotcom-rest-api).
  • To find the ‘release_id’ query the ‘GET /repos/{owner}/{repo}/releases/latest’ endpoint (https://docs.github.com/rest/releases/releases#get-the-latest-release).
  • If you upload an asset with the same filename as another uploaded asset, you’ll receive an error and must delete the old file before you can re-upload the new asset.

Endpoint: POST /repos/{owner}/{repo}/releases/{release_id}/assets API version: 2026-03-10

EXAMPLES

EXAMPLE 1

' -InFile '.\file.zip'

Invokes POST /repos/{owner}/{repo}/releases/{release_id}/assets

PARAMETERS

-Accept

The Accept header (media type) of the request Default value: application/vnd.github+json

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: System.Management.Automation.SwitchParameter
DefaultValue: ''
SupportsWildcards: false
Aliases:
- cf
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ContentType

The media type of the uploaded file, for example application/zip Default value: application/octet-stream

Type: System.String
DefaultValue: application/octet-stream
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-InFile

The path of the file whose content is uploaded as the request body

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Label

The label value of the request

Query parameter [ label ]

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Name

The name value of the request

Query parameter [ name ]

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Owner

The account owner of the repository. The name is not case sensitive.

Path parameter [ owner ]

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 0
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ReleaseId

The unique identifier of the release.

Path parameter [ release_id ]

Type: System.Int64
DefaultValue: 0
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 2
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Repo

The name of the repository without the ‘.git’ extension. The name is not case sensitive.

Path parameter [ repo ]

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 1
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-WhatIf

Runs the command in a mode that only reports what would happen without performing the actions.

Type: System.Management.Automation.SwitchParameter
DefaultValue: ''
SupportsWildcards: false
Aliases:
- wi
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

Objects with properties named like the path parameters can be piped to this function

{{ Fill in the Description }}

System.String

{{ Fill in the Description }}

System.Int64

{{ Fill in the Description }}

OUTPUTS

The response of the GitHub API (objects

{{ Fill in the Description }}

NOTES

OperationId: repos/upload-release-asset Category: releases / assets Upload endpoint: sent to the uploads.github.com base uri