Freedom.System.Error
Freedom.System.Error

Reputation: 43

How to add Path Parameter on http client C#

How to add Path Parameter on http client C# URL example https://testurl/accounts/product/:productid/user/:userid?fields=Attributes

I tried adding with KeyValuePair but no luck.

enter image description here

Upvotes: 2

Views: 3320

Answers (1)

nzrytmn
nzrytmn

Reputation: 6951

You can use string interpolation and concatenation. I think this is what you are askin for;

        int userId = 1;
        string url = $"https://testurl/accounts/product/:productid/user/{userId}";
       // Add here if there is any condtion if() or any loop
        url += "?fields=Attributes";

Upvotes: 2

Related Questions