unchase / Unchase.Odata.Connectedservice

:scroll: A Visual Studio extension for connecting to OData services with generating client-side C# proxy-classes
Apache License 2.0
44 stars 13 forks source link

BUG: Request.Method and Request.HttpWebRequest.Method are different #24

Closed Gforse12 closed 4 years ago

Gforse12 commented 4 years ago

When deleting a Entity and then calling SaveChanges i noticed that the server returned an error. While investigating with wireshark i discovered that the HTTP method was set to POST instead of delete. I debugged the values in the event SendingRequest2.

The screenshot below demonstrates the bug where ActualMehtod is POST and the method is DELETE (which is the right one): Annotation 2020-01-08 155514

There is a simple fix bij adding this line to the SendingRequest2 Event:

Private Sub WebCon_SendingRequest2(sender As Object, e As SendingRequest2EventArgs)
        Dim request As HttpWebRequestMessage = CType(e.RequestMessage, HttpWebRequestMessage)
        request.HttpWebRequest.Method = request.Method ' This fixes the bug
End Sub
unchase commented 4 years ago

Did you use the SaveChanges method from the Microsoft.Data.Services.Client NuGet package?

Gforse12 commented 4 years ago

I used the SaveChanges from the System.Data.Services.Client of type SaveChanges(options As SaveChangesOptions) As DataServiceResponse in DataServiceContext

unchase commented 4 years ago

Then also create the same issue in the repository.

Gforse12 commented 4 years ago

Oké posted the issue on that repository: #1627