Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
b3b00 opened this issue Jan 30, 2024 · 2 comments · May be fixed by #2871
Open
1 task done

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

b3b00 opened this issue Jan 30, 2024 · 2 comments · May be fixed by #2871
Labels
Type: Bug Something isn't working as documented

Comments

@b3b00
Copy link

b3b00 commented Jan 30, 2024

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
@b3b00 b3b00 added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Jan 30, 2024
@b3b00 b3b00 changed the title [BUG]: exception [BUG]: exception "mediatype is null or empty" when trying to delete file Jan 30, 2024
b3b00 added a commit to b3b00/octokit.net that referenced this issue Jan 30, 2024
@b3b00
Copy link
Author

b3b00 commented Jan 30, 2024

I've debugged and found a quick fix (see 3848a79). But I guess it's a bit too optimistic as the Connection.Deletemethod may be used to delete other resources that does not need content-type to be setted if no body is send with the HTTP DELETE request.

@b3b00 b3b00 linked a pull request Jan 30, 2024 that will close this issue
2 tasks
@b3b00
Copy link
Author

b3b00 commented Jan 30, 2024

I've forgot to specify my dotnet env :

`
SDK .NET :
Version: 8.0.101
Commit: 6eceda187b
Workload version: 8.0.100-manifests.69afb982

Environnement d'exécution :
OS Name: Windows
OS Version: 10.0.19044
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.101\

Charges de travail .NET installées :
Workload version: 8.0.100-manifests.69afb982
Il n'y a aucune charge de travail installée à afficher.

Host:
Version: 8.0.1
Architecture: x64
Commit: bf5e279d92
`

@kfcampbell kfcampbell removed the Status: Triage This is being looked at and prioritized label Feb 2, 2024
b3b00 pushed a commit to b3b00/octokit.net that referenced this issue Feb 4, 2024
b3b00 pushed a commit to b3b00/octokit.net that referenced this issue Feb 4, 2024
…n-deleting-file

* main:
  [Feat] Allow build version to be passed in to build.ps1 via command line (octokit#2864)
  [Feat] Add Repository Autolinks Client (octokit#2868)
b3b00 added a commit to b3b00/octokit.net that referenced this issue Feb 4, 2024
nickfloyd added a commit to b3b00/octokit.net that referenced this issue Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented
Projects
Status: 🔥 Backlog
Development

Successfully merging a pull request may close this issue.

2 participants