Need to build URL encoded query from model object for HttpClient
My Model is
class SaveProfileRequest
{
public string gName { get; set; }
public string gEmail { get; set; }
public long gContact { get; set; }
public string gCompany { get; set; }
public string gDeviceID { get; set; }
public string Organization { get; set; }
public string profileImage { get; set; }
public string documentImagefront { get; set; }
public string documentImageback { get; set; }
}
SaveProfileRequest request = new SaveProfileRequest() { gName = name, gEmail = email, gContact = phonenumber, gCompany = company,
gDeviceID = deviceId, Organization = "", profileImage = "", documentImageback = "", documentImagefront = "" };
string response = await RequestProvider.PostAsync<string, SaveProfileRequest>(uri, request);
I have a working code for content type JSON
content = new StringContent(JsonConvert.SerializeObject(data));
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
Where data is of type TInput
Tried
content = new StringContent(System.Net.WebUtility.UrlEncode(JsonConvert.SerializeObject(data)));
content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
but didn't workout