How to Pass special character in Web Api Post method?
I am save the special character like '&',''' in web api via post method.
Problem is when i am pass the special character via parameter then special character remove the web api and save the value without special character.
I am 1st create a web api then this web api call the your asp.net project. I am call the web api via Web client.
Please see the exp:
string URI = ApiBaseURL + "project/Updateproject";
string myParameters = "ProjectId=" + projectid + "&ProjectStatusId=" + projectstatusid + "&ProjectName=" +
projectname + "&ProjectImage=" + fileName + "&Description=" + description + "&FloorPlan=" + floorplan +
"&ProjectAddress=" + address + "&ProjectCategoryId=" + projectcategoryid + "&CityId=" +
cityid + "&ProjectBudgetLowPrice=" + budgetlowprice + "&ProjectBudgetHighPrice=" + budgethighprice +
"&ProjectLogo=" + ProjectLogo + "&YoutubeLink=" + youtubelink + "&FeaturePropertyFlag=" + featuredpropertyflag
+ "&Property=" + property + "&Video=" + videofile + "&Phone=" + phone + "&SocialContactNo=" + socialPh +
"&PpcContactNo=" + ppcphone + "&ThreeSixtyDegreeVideo=" + threesixtyfilelink + "&LoyaltyPoint=" + loyaltypoint
+ "&ProjectDurationId=" + ProjectDurationId + "&latitude=" + latitude + "&longitude=" + longitude +
"&PhotoGallaryShrtDesc=" + PhotoGallaryShrtDesc + "&LocationShrtDesc=" + LocationShrtDesc + "&LandingViewFlag="
+ LandingViewFlag + "&ProjectBudgetRange=" + ProjectBudgetRange + "&ProjectLinkId=" + ProjectLinkId + "&ProjectExternalLink=" + ProjectExternalLink;
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
HtmlResult = wc.UploadString(URI, myParameters);
}
What I have tried:
How to Pass special character in Web Api Post method?
I am save the special character like '&',''' in web api via post method.
Problem is when i am pass the special character via parameter then special character remove the web api and save the value without special character.
I am 1st create a web api then this web api call the your asp.net project. I am call the web api via Web client.
Please see the exp:
string URI = ApiBaseURL + "project/Updateproject";
string myParameters = "ProjectId=" + projectid + "&ProjectStatusId=" + projectstatusid + "&ProjectName=" +
projectname + "&ProjectImage=" + fileName + "&Description=" + description + "&FloorPlan=" + floorplan +
"&ProjectAddress=" + address + "&ProjectCategoryId=" + projectcategoryid + "&CityId=" +
cityid + "&ProjectBudgetLowPrice=" + budgetlowprice + "&ProjectBudgetHighPrice=" + budgethighprice +
"&ProjectLogo=" + ProjectLogo + "&YoutubeLink=" + youtubelink + "&FeaturePropertyFlag=" + featuredpropertyflag
+ "&Property=" + property + "&Video=" + videofile + "&Phone=" + phone + "&SocialContactNo=" + socialPh +
"&PpcContactNo=" + ppcphone + "&ThreeSixtyDegreeVideo=" + threesixtyfilelink + "&LoyaltyPoint=" + loyaltypoint
+ "&ProjectDurationId=" + ProjectDurationId + "&latitude=" + latitude + "&longitude=" + longitude +
"&PhotoGallaryShrtDesc=" + PhotoGallaryShrtDesc + "&LocationShrtDesc=" + LocationShrtDesc + "&LandingViewFlag="
+ LandingViewFlag + "&ProjectBudgetRange=" + ProjectBudgetRange + "&ProjectLinkId=" + ProjectLinkId + "&ProjectExternalLink=" + ProjectExternalLink;
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
HtmlResult = wc.UploadString(URI, myParameters);
}