This is the POST Request, it works.
curl -X POST --header 'Accept: application/json'
'http://mywebsite.com/api/CompleteService?refId=12345&productPrice=600'
How to send this request using C#
=> HttpClient
=> client.PostAsync()
method?
Two methods have been tried but both failed.
Method 1 (Failed, Response 404)
string url = "http://mywebsite.com/api/CompleteService";
string refId = "12345";
string price= "600";
string param = $"refId ={refId}&productPrice={price}";
HttpContent content = new StringContent(param, Encoding.UTF8, "application/json");
HttpResponseMessage response = client.PostAsync(url, content).Result;
This would only work if API is to accept a request body, not query strings.
Method 2 (Failed, Response 404) https://stackoverflow.com/a/37443799/7768490
var parameters = new Dictionary<string, string> { { "refId ", refId }, { "productPrice", price} };
var encodedContent = new FormUrlEncodedContent(parameters);
HttpResponseMessage response = client.PostAsync(url, encodedContent)