问题
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