Skip to content

C# Code Snippet needs a clear handlers to work. #23

Description

@jordanwalsh23

Our API requires that customers send vnd mime types in both the Accept and Content-Type headers.

With the C# example, the following code is provided:

var client = new RestClient("https://api.whispir.com/messages?apikey=REPLACE_ME");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/vnd.whispir.message-v1+json");
request.AddHeader("accept", "application/vnd.whispir.message-v1+json");
request.AddHeader("authorization", "<REPLACE_ME>");
request.AddParameter("application/vnd.whispir.message-v1+json", "{\"to\":\"<REPLACE_ME>\",\"subject\":\"<REPLACE_ME>\",\"body\":\"<REPLACE_ME>\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

The problem though is that the request.AddHeader method is not respected unless the following code is provided on line 2:

client.ClearHandlers();

This code clears the default handlers allowing the user to set custom headers.

Can you please include this in your out of the box rendering of C# code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions