:relfileprefix: ../../../
[#4BD7F242A7AB871BBBC81B7C1A1B0427D44A265F]

= Function url_base::set_encoded_params

pass:v,q[Set the query params]


== Synopsis

Declared in header `</boost/url/url_base.hpp#L2303[boost/url/url_base.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
xref:boost/urls/url_base.adoc[url_base]&
set_encoded_params(initializer_list<xref:boost/urls/param_pct_view.adoc[param_pct_view]> ps) noexcept;
----

== Description

pass:v,q[This sets the query params to the elements] pass:v,q[in the list, which may contain]
pass:v,q[percent-escapes and can be empty.]
pass:v,q[An empty list of params is distinct from]
pass:v,q[having no query.]
pass:v,q[Escapes in the string are preserved,]
pass:v,q[and reserved characters in the string]
pass:v,q[are percent-escaped in the result.]

=== Example
[,cpp]
----
assert( url( "http://example.com" ).set_encoded_params( {"id", "42"} ).encoded_query() == "id=42" );
----

=== Postconditions
[,cpp]
----
this->has_query() == true
----

=== Complexity
pass:v,q[Linear.]

=== Exception Safety
pass:v,q[Strong guarantee.]
pass:v,q[Calls to allocate may throw.]
pass:v,q[Exceptions thrown on invalid input.]

=== BNF
[,cpp]
----
query           = *( pchar / "/" / "?" )

query-param     = key [ "=" value ]
query-params    = [ query-param ] *( "&" query-param )
----

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.4[3.4. Query (rfc3986)]

* link:https://en.wikipedia.org/wiki/Query_string[Query string (Wikipedia)]



== Return Value

* `` 


== Parameters

|===
| Name | Type 

| *ps*
| `initializer_list`

|===



