user113262: I tried the following commands, but none of them worked.
-getblocktemplate "segwit"
-Error: Error parsing JSON: segwit

-getblocktemplate ("segwit")
-Error: Error parsing JSON: segwit

-getblocktemplate "rules": ["segwit"]
-Error: Error parsing JSON: rules:

-getblocktemplate {"rules": ["segwit"]}
-Error: Error parsing JSON: {rules:

-getblocktemplate
-getblocktemplate must be called with the segwit rule set (call with {"rules": ["segwit"]}) (code -8)

-getblocktemplate {"rules": ["segwit"]}
-Error: Error parsing JSON: {rules:

How can I use this command correctly?

user48884: The GUI's debug console operates similarly to a shell. It needs quotes around the entire JSON string so that it is first interpreted as a string before the JSON is parsed. Then, if you used double quotes, you need to escape the quotes that are part of the JSON so that they aren't misinterpreted.
A valid way of writing this command is
getblocktemplate "{\"rules\":[\"segwit\"]}"

Alternatively, to avoid additional escaping, you can use single quotes on the outside:
getblocktemplate '{"rules":["segwit"]}'


113262: <p>I tried the following commands, but none of them worked.</p>
<pre><code>-getblocktemplate &quot;segwit&quot;
-Error: Error parsing JSON: segwit

-getblocktemplate (&quot;segwit&quot;)
-Error: Error parsing JSON: segwit

-getblocktemplate &quot;rules&quot;: [&quot;segwit&quot;]
-Error: Error parsing JSON: rules:

-getblocktemplate {&quot;rules&quot;: [&quot;segwit&quot;]}
-Error: Error parsing JSON: {rules:

-getblocktemplate
-getblocktemplate must be called with the segwit rule set (call with {&quot;rules&quot;: [&quot;segwit&quot;]}) (code -8)

-getblocktemplate {&quot;rules&quot;: [&quot;segwit&quot;]}
-Error: Error parsing JSON: {rules:
</code></pre>
<p>How can I use this command correctly?</p>
 48884: <p>The GUI's debug console operates similarly to a shell. It needs quotes around the entire JSON string so that it is first interpreted as a string before the JSON is parsed. Then, if you used double quotes, you need to escape the quotes that are part of the JSON so that they aren't misinterpreted.</p>
<p>A valid way of writing this command is</p>
<pre><code>getblocktemplate &quot;{\&quot;rules\&quot;:[\&quot;segwit\&quot;]}&quot;
</code></pre>
<p>Alternatively, to avoid additional escaping, you can use single quotes on the outside:</p>
<pre><code>getblocktemplate '{&quot;rules&quot;:[&quot;segwit&quot;]}'
</code></pre>
