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

[Body] cannot be used in Get requests #234

Closed
escamoteur opened this issue May 19, 2016 · 2 comments
Closed

[Body] cannot be used in Get requests #234

escamoteur opened this issue May 19, 2016 · 2 comments
Labels

Comments

@escamoteur
Copy link

Hi,

I was really suprised to find out that parameters used in Get requests are automatically send a HTTP Queries.
I want to have them sent in the Body and not as Query strings. So I tried to Apply the Body Attribute:

        [Get("/sync/day")]
        Task<MyDay> GetDay([Body] DateTime utcDateOfDay, [Header("Authorization")] string authorization);

I receive this Exception:

System.Net.ProtocolViolationException

Inhaltsteil mit diesem Verbtyp kann nicht gesendet werden.

   bei System.Net.HttpWebRequest.CheckProtocol(Boolean onRequestStream)
   bei System.Net.HttpWebRequest.BeginGetRequestStream(AsyncCallback callback, Object state)
   bei System.Net.Http.HttpClientHandler.StartGettingRequestStream(RequestState state)
   bei System.Net.Http.HttpClientHandler.PrepareAndStartContentUpload(RequestState state)
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Refit.RequestBuilderImplementation.<>c__DisplayClass2e`1.<<buildCancellableTaskFuncForMethod>b__2d>d__30.MoveNext() in y:\code\paulcbetts\refit\Refit\RequestBuilderImplementation.cs:Zeile 316.
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---

Cheers
Thomas

@flagbug
Copy link
Member

flagbug commented May 19, 2016

A GET request can't have a body, you either have to send a POST request, or add query parameters

@escamoteur
Copy link
Author

Yes, sorry, I found out just a second before. While testing nancyFx with their testing framework this was no problem.

@lock lock bot added the outdated label Jun 25, 2019
@lock lock bot locked and limited conversation to collaborators Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants