RestSharp - Get Request returning Cannot send a content-body with this verb-type

Viewed 32

I am working on connecting to an API. I need to send a GET request, but I am getting the error:

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

I am using RestSharp Library and following their documentation. I am able to successfully call the API using the POST method, but one of the calls requires to use of the GET method.

Dim options = New RestClientOptions(_baseUrl)
        Dim client As New RestClient(options)
Dim access_token as String = "123454"
        client.Authenticator = New OAuth2AuthorizationRequestHeaderAuthenticator(access_token, "Bearer")
Dim JsonRequest As String = "{""id"": ""2345-2323-435-45345-342342352""}"
        Dim request = New RestRequest(EndPoint, Method.Get)
        request.AddStringBody(JsonRequest, ContentType.None)
        Dim response = Await client.ExecuteGetAsync(request)

I've read up on other StackOverflow posts and found this one.

I am able to get a response via POSTMAN. How can I send a GET request with required JSon data.

0 Answers
Related