Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

Cannot send a content-body with this verb-type. #27

Closed
DeniseDornell opened this issue Feb 5, 2019 · 5 comments
Closed

Cannot send a content-body with this verb-type. #27

DeniseDornell opened this issue Feb 5, 2019 · 5 comments
Assignees

Comments

@DeniseDornell
Copy link

Client.Checkout.GetOrder(orderId).Result and Client.OrderManagement.GetOrder(orderId).Result is just awaiting without any result

It works if I create a own request with HttpClient

@martingust
Copy link
Contributor

@DeniseDornell Do you get any errors?

You can try inspect to see the request and response JSON? You can implement a custom JSON serializer in order to do that https://github.com/klarna/kco_rest_dotnet/blob/v3.0/Klarna.Rest/Klarna.Rest.Core.Examples/CustomJsonSerializer.cs

Also what happens if you use async/await instead of .Result? Do you get any better error?

@ErikGranly
Copy link

ErikGranly commented Mar 8, 2019

Getting the following error using both these methods(Client.Checkout.GetOrder(orderId).Result and Client.OrderManagement.GetOrder(orderId).Result )

Details:
Cannot send a content-body with this verb-type.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.ProtocolViolationException: Cannot send a content-body with this verb-type.
Stack Tace:

[ProtocolViolationException: Cannot send a content-body with this verb-type.]   
System.Net.HttpWebRequest.CheckProtocol(Boolean onRequestStream) +6793482   
System.Net.HttpWebRequest.BeginGetRequestStream(AsyncCallback callback, Object state) +59   
System.Net.Http.HttpClientHandler.StartGettingRequestStream(RequestState state) +129   
System.Net.Http.HttpClientHandler.PrepareAndStartContentUpload(RequestState state) +307   
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99   
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58   
Klarna.Rest.Core.Commuication.d__13.MoveNext() +430   
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99   
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58   
Klarna.Rest.Core.Commuication.d__10`1.MoveNext() +194   
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99   
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58   
Klarna.Rest.Core.Store.d__2.MoveNext() +176  

@alexions
Copy link
Contributor

#35

@alexions
Copy link
Contributor

Thanks to the Guillermo

With his help we found an issue (I suppose for the older versions of .NET Core) when sending the GET requests.

HTTP 1.1. Specification says, that GET request should not have a body (but it can have), but the reality, you will get a verb-type exception when sending the GET with a body inside.

So the fix allows to set null when no body data instead of string.Empty

@freethan
Copy link
Contributor

Resolved by #35 , please get in touch if the issue persists

@alexions alexions changed the title Client.Checkout.GetOrder and Client.OrderManagement.GetOrder awaiting without any result Cannot send a content-body with this verb-type. Mar 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants