angular2 - http post request parameters prevent encoding the special characters

烂漫一生 提交于 2021-01-28 09:09:13

问题


i am trying to make a HTTP post request. When using the below code, the request parameters are null in the server side.

let url = apiURL;
let body = { 'tenantId': tenantId, 'vsLoginToken': vsLoginToken, 'branchId': branchId };
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this._http.post(url, body, options).map(res => res.json()).
  catch(error => Observable.throw(error.json().error || 'Server error'));

If i remove the 'options' parameter in the HTTP post method i am getting the request parameters values. But the parameter vsLoginToken has some special characters. The original vsLoginToken value is like 'ax6a+kao+c'. But when i get this value in the server side it is like 'ax6a kao c'. As you can see the '+' characters are replaced by spaces and i want to prevent this encoding. How can i prevent this encoding? (i don't want to use URLSearchParam QueryEncoder) Any other answers will be great. Thanks

来源:https://stackoverflow.com/questions/42023170/angular2-http-post-request-parameters-prevent-encoding-the-special-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!