Diptyajit Dey

Diptyajit Dey

  • NA
  • 98
  • 22k

How to Pass special character in Web API Post method?

Jul 17 2017 3:03 AM
How to Pass special character in Web API Post method? I am saving the special character like '&',''' in web api via post method.
 
Problem is when I am passing the special character via parameter then special character is being removed by the Web API and the value is being saved without special character.
 
I have first created a Web API. Then this Web API call the your asp.net project. I am calling the Web API via Web client. Please see the exp:
  1. string URI = ApiBaseURL + "project/Updateproject";  
  2. string myParameters = "ProjectId=" + projectid + "&ProjectStatusId=" + projectstatusid +  
  3. "&ProjectName=" + projectname + "&ProjectImage=" + fileName + "&Description=" +  
  4. description + "&FloorPlan=" + floorplan + "&ProjectAddress=" + address +  
  5. "&ProjectCategoryId=" + projectcategoryid + "&CityId=" + cityid +  
  6. "&ProjectBudgetLowPrice=" + budgetlowprice + "&ProjectBudgetHighPrice=" +  
  7. budgethighprice + "&ProjectLogo=" + ProjectLogo + "&YoutubeLink=" + youtubelink +  
  8. &FeaturePropertyFlag=" + featuredpropertyflag + "&Property=" + property + "&Video=" +  
  9. "&Phone=" + phone + "&SocialContactNo=" + socialPh + "&PpcContactNo=" + ppcphone + "&ThreeSixtyDegreeVideo=" + threesixtyfilelink + "&LoyaltyPoint=" + loyaltypoint +  
  10. "&ProjectDurationId=" + ProjectDurationId + "&latitude=" + latitude + "&longitude=" +  
  11. longitude + "&PhotoGallaryShrtDesc=" + PhotoGallaryShrtDesc + "&LocationShrtDesc=" +  
  12. LocationShrtDesc + "&LandingViewFlag=" + LandingViewFlag + "&ProjectBudgetRange="  
  13. + ProjectBudgetRange + "&ProjectLinkId=" + ProjectLinkId + "&ProjectExternalLink=" +  
  14. ProjectExternalLink;  
  15. using (WebClient wc = new WebClient())  
  16. {  
  17. wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";  
  18. HtmlResult = wc.UploadString(URI, myParameters);  
  19. }  

Answers (1)