Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing Rest Request Headers #959

Closed
nilesh-shah opened this issue May 24, 2017 · 6 comments
Closed

Removing Rest Request Headers #959

nilesh-shah opened this issue May 24, 2017 · 6 comments

Comments

@nilesh-shah
Copy link

Is there a way by which I can remove the header value from RestSharp request.
Ex. I have added token in the request header and after request execution realized that, token is expired. I wanted to apply regenerated to token to request. If I simply add it using AddHeader, it creates a new parameter entry with same name, and does not override the earlier one.

Looking for a way where either i can remove and add or update header.

If this is not supported,

  1. one can enumerate the parameters and find a parameter by parameter type and name
  2. once found, remove it from Parameters list (using List.Remove)
  3. Then, add it again

I can generate PR by exposing the method. Please suggest if this is good to have feature in the library.

Thanks
Nilesh

@a3349384
Copy link

a3349384 commented Jul 8, 2017

request.Parameters.remove()

@alexeyzimarev
Copy link
Member

You can submit a PR with AddOrUpdateHeader like it was done for parameters:

public IRestRequest AddOrUpdateParameter(Parameter p)

But don't forget method xml documentation.

@alexeyzimarev
Copy link
Member

Any luck submitting a PR for this?

@axa88
Copy link

axa88 commented Aug 31, 2018

Im having the same issue as the OP, seems this was never done, i second the notion.
Otherwise, i think it would help those unfamiliar get it done.

@sayhicoelho
Copy link

For client instance, just: client.RemoveDefaultParameter("Authorization");

@alexeyzimarev
Copy link
Member

I think it is already fixed. We only add default parameters if there is no parameter with the same name available in the list of request parameters. It can be overridden by AllowMultipleDefaultParametersWithSameName, which is false by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants