Skip to content

[BUG]: exception "mediatype is null or empty" when trying to delete file #2870

Closed
@b3b00

Description

@b3b00

What happened?

When trying to delete a file using

var deleteRequest =   new DeleteFileRequest($"delete file", content.content.Sha);
await gitHubClient.Repository.Content.DeleteFile(RepositoryId,$"notes/{noteName}.md" , deleteRequest);

I get the following exception

System.ArgumentException: The value cannot be null or empty. (Parameter 'mediaType')
   at System.Net.Http.Headers.MediaTypeHeaderValue.CheckMediaTypeFormat(String mediaType, String parameterName)
   at System.Net.Http.StringContent..ctor(String content, Encoding encoding, String mediaType)
   at Octokit.Internal.HttpClientAdapter.BuildRequestMessage(IRequest request) in /_/Octokit/Http/HttpClientAdapter.cs:line 147
   at Octokit.Internal.HttpClientAdapter.Send(IRequest request, CancellationToken cancellationToken, Func`2 preprocessResponseBody) in /_/Octokit/Http/HttpClientAdapter.cs:line 48
   at Octokit.Connection.RunRequest(IRequest request, CancellationToken cancellationToken, Func`2 preprocessResponseBody) in /_/Octokit/Http/Connection.cs:line 761
   at Octokit.Connection.Run[T](IRequest request, CancellationToken cancellationToken, Func`2 preprocessResponseBody) in /_/Octokit/Http/Connection.cs:line 752
   at Octokit.Connection.Delete(Uri uri, Object data) in /_/Octokit/Http/Connection.cs:line 602

Versions

latest version : octokit.net v9.1.1 (did not try previous versions)

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleUsed by stalebot to clean houseType: BugSomething isn't working as documented

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions