0

We have upgraded the RestSharp NuGet package in our Application from v106 to version 108, and applied the migration recommendations as described here: RestSharp v107 Migration Guide, but somehow when a PostAsync is being executed in our application an error 'Method not allowed' occurs. In the code below there are two lines that start with 'Request.AddHeader('. One of the recommendations is to not have these lines. But even when I remove these lines from the code, I still get the same error. What goes wrong?

Try
    Dim nieuwEvent = EventModelSessie(tijdblokDP)
    Dim client = New RestClient(_graphUrl)
    Dim response As RestSharp.RestResponse
    Dim aantalKeerVerstuurd As Integer = 0
    Do
        Dim request = New RestRequest((Convert.ToString("/") & _version) + "/users/" + dokterplan365Account + "/Events", Method.Post)
        request.AddHeader("Authorization", "Bearer " + _token.Result)
        request.AddHeader("Content-Type", "application/json")
        Dim jsonBody = JsonConvert.SerializeObject(nieuwEvent)
        request.AddParameter("application/json", jsonBody, ParameterType.RequestBody)
        response = Await client.PostAsync(Of RestResponse)(request, Nothing)
        Dim content = response.Content
Martijn
  • 1
  • 1

0 Answers0