[#boost-urls-url_base-set_params]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_base.adoc[url&lowbar;base]::set&lowbar;params
:relfileprefix: ../../../
:mrdocs:


Set the query params

== Synopsis


Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_base.hpp#L2278[boost&sol;url&sol;url&lowbar;base&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/url_base.adoc[url&lowbar;base]&
set&lowbar;params(
    std::initializer&lowbar;list&lt;xref:boost/urls/param_view.adoc[param&lowbar;view]&gt; ps,
    xref:boost/urls/encoding_opts.adoc[encoding&lowbar;opts] opts = &lcub;&rcub;) noexcept;
----

== Description


This sets the query params to the list        of param&lowbar;view, which can be empty&period;

An empty list of params is distinct from        having no params&period;

Reserved characters in the string are        percent&hyphen;escaped in the result&period;


=== Example

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

=== Postconditions

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

=== Exception Safety

Strong guarantee&period;        Calls to allocate may throw&period;


=== Complexity

Linear&period;


=== 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)</a>
        @li <a href=[&colon;&sol;&sol;en&period;wikipedia&period;org&sol;wiki&sol;Query&lowbar;string&quot;            &gt;Query string (Wikipedia)]



== Parameters


|===
| Name | Description

| *ps*
| The params to set&period;


| *opts*
| The options for encoding&period;


|===

== See Also


xref:boost/urls/url_base/encoded_params-06.adoc[encoded&lowbar;params],            xref:boost/urls/url_base/remove_query.adoc[remove&lowbar;query],            xref:boost/urls/url_base/set_encoded_query.adoc[set&lowbar;encoded&lowbar;query],            xref:boost/urls/url_base/set_query.adoc[set&lowbar;query]&period;






[.small]#Created with https://www.mrdocs.com[MrDocs]#
