jyn
jyn

Reputation: 3

Accessing the requested url with the query helper

what I need;

api/GetCharacteristicsBulk?versionCode=RTUK8L1&language=2 go to this address.

 var urlCode = selectedVersionCode + "&" + "language=" + language;
 string url = QueryHelpers.AddQueryString($"{_urls.BaseUrl}{_urls.SapCharacteristicService.GetCharacteristicsBulk}", "versionCode", System.Web.HttpUtility.UrlDecode(urlCode)); 

when i run this; api/GetCharacteristicsBulk?RTUK8L1%262=RTUK8L1%25262. I get a result as above.

api/GetCharacteristicsBulk?versionCode=RTUK8L1&language=2 What should I do to get the output?

Upvotes: 0

Views: 31

Answers (1)

Karen Payne
Karen Payne

Reputation: 5102

The following uses a string AddQueryString(String, IDictionary<String,String>) overload will give you the correct result.

Dictionary<string, string> queryArguments = new()
{
    { "versionCode", "RTUK8L1" },
    { "language", "2" }
};

var results = QueryHelpers.AddQueryString(
    "api/GetCharacteristicsBulk", 
    queryArguments);

Result api/GetCharacteristicsBulk?versionCode=RTUK8L1&language=2

Upvotes: 1

Related Questions