0

I have to send some parameters in the query string to the GET request, but unable to format where the value has "&".Below is the URL that I have to send.

http://localhost:4200/DeletePoolDetails?COVERAGE_DS=BI Dwelling & Dwelling Communities&PROGRAM_POLICY_ID=127447&RequestType=DeleteTaxes

in this "BI Dwelling & Dwelling Communities" is the value which has "&", because of this when post it is treating after "&" as a new parameter.

http://localhost:4200/DeletePoolDetails?COVERAGE_DS=BI%20Dwelling%20&%20Dwelling%20Communities%20%20%20%20&PROGRAM_POLICY_ID=127447%20%20%20%20&RequestType=DeleteTaxes
Pavan Manjunath
  • 27,404
  • 12
  • 99
  • 125
Rama Mohan
  • 151
  • 1
  • 7
  • Possible duplicate of [escaping ampersand in url](https://stackoverflow.com/questions/16622504/escaping-ampersand-in-url) – Talha Junaid Aug 24 '18 at 17:05

1 Answers1

0

I got an answer for this. I have take all URL parametsr like below.

const url = "Http://******"
const params = {      
  COVERAGE_DS: BI Dwelling & Dwelling Communities,
  PROGRAM_POLICY_ID:127447,
  RequestType:DeleteTaxes
} 
let requestOptions = this.getHeaderObj(configHeader);//configHeader optional 
requestOptions['params'] = params;

return this._http.post(url, JSON.stringify(data), requestOptions);//JSON.stringify(data) is request body if you want to send any

requestOptions['params'] ----if we pass this parameter internally it will convert and post exact data with special characters as well with out any issues. 
Saravanan Sachi
  • 2,572
  • 5
  • 33
  • 42
Rama Mohan
  • 151
  • 1
  • 7