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

CC BY-SA 4.0
2021-03-30T17:07:03.720Z
2021-03-30T17:07:03.720Z
Ava Chow
<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>

<json-rpc><rpc-error-4>
How do I use the getblocktemplate RPC command of Bitcoin Core GUI? I tried the following usages but none of them worked
GoneV
# How do I use the getblocktemplate RPC command of Bitcoin Core GUI? I tried the following usages but none of them worked

(Asked by: username_0 on 2021-03-30)

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?

**Tags:** json-rpc, rpc-error-4


---

## 1 answers

### Answer by username_1 on 2021-03-30. Score: 2 | Accepted answer

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"]}'


---

