Skip to content

Fix issue #158#165

Closed
ttzztztz wants to merge 2 commits intopostmanlabs:developfrom
ttzztztz:csharp_issue_fix
Closed

Fix issue #158#165
ttzztztz wants to merge 2 commits intopostmanlabs:developfrom
ttzztztz:csharp_issue_fix

Conversation

@ttzztztz
Copy link
Contributor

@ttzztztz ttzztztz commented Feb 23, 2020

I fixed issue #158 by changing the C# RestSharp API .

As He says, the

request.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0");

doesn't work and will be overwritten to a default UA, the official solution is to use

client.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0";

Instead of Add Header.

So I just fix it by checking whether a Header's key equals to User-Agent, If so, output the client.UserAgent = "...", otherwise, output the request.AddHeader(..., ...).

So It will work and fix the issues.

@ttzztztz ttzztztz requested a review from shreys7 February 23, 2020 11:20
@ankit-m
Copy link

ankit-m commented Feb 24, 2020

@ttzztztz can you add a comment on the GH issue #158 saying that you are working on it.

@ankit-m
Copy link

ankit-m commented Feb 24, 2020

@ttzztztz can you add a comment on the GH issue #158 saying that you are working on it.

Same for all issues you have created a PR for.

@ttzztztz
Copy link
Contributor Author

@ttzztztz can you add a comment on the GH issue #158 saying that you are working on it.

OK, I added very detail descriptions on the background of the issues and my solution.
Thank you!

@shreys7
Copy link
Member

shreys7 commented Feb 24, 2020

Hey @ttzztztz, thanks for the contribution. Can you add an appropriate unit test for this fix?
You can refer the tests here:
https://github.com/postmanlabs/postman-code-generators/blob/develop/codegens/csharp-restsharp/test/unit/convert.test.js

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

Successfully merging this pull request may close these issues.

3 participants