I am trying to encode query parameter values in Angular 7. But I get 400 Bad Request status code, when my query parameter values contain any special characterFailed Request URL:http://localhost/api/67/cardvalues?parentcardvalues=STONE&parentcardvalues=STONE%20AGEHowever, I get 200 OK status code , when my query parameter values do not contain any special characters.Successful Request URL:http://localhost/api/67/cardvalues?parentcardvalues=STONE&parentcardvalues=STONEThe expected request url has to be like http://localhost/cardvalues?parentcardvalues=VALUE1&parentcardvalues=VALUE2Below is my code,parentcardvalues=["STONE","STONE AGE"]let myparams = new HttpParams(); if(parentcardvalues.length != 0) parentcardvalues.forEach((value) => { myparams = myparams.append( 'parentcardvalues', encodeURIComponent(value) );}); this.http.get(this.baseUrl + 'api/67/cardvalues', {params: myparams});The Swagger specification is,Curlcurl -X GET "http://localhost/api/cardvalues?parentcardvalues=STONE&parentcardvalues=STONE%20AGE" -H "accept: application/json"Request URLhttp://localhost/api/cardvalues?parentcardvalues=STONE&parentcardvalues=STONE%20AGE 解决方案 you can decode your params using:decodeURIComponent(encodedURI_string)more information here 这篇关于如何在 Angular 7 中编码包含特殊字符的查询参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-17 04:38