title: How to add a numeric value with unit (eg. 1500 kW) using WbQuantity() function, unsuccessful using tutorial
body: <p>I'm creating a semi-automated tool in Python, using pywikibot, to import data from TOP500 database into Wikidata, following <a href="https://www.wikidata.org/wiki/Wikidata:Creating_a_bot" rel="nofollow noreferrer">this</a> and <a href="https://www.wikidata.org/wiki/Wikidata:Pywikibot_-_Python_3_Tutorial/Quantities_and_Units" rel="nofollow noreferrer">this</a> tutorial. (Is my first time programming in Python).</p>
  
  <p>It ran fine, until the script attempts to commit a numeric value within a unit (for example, <a href="https://www.wikidata.org/wiki/Q2442043" rel="nofollow noreferrer">Pleiades (<code>Q2442043</code>)</a> → <a href="https://www.wikidata.org/wiki/Property:P2791" rel="nofollow noreferrer">power consumed (P2791)</a> → 4407.00 <strong>kW</strong>). The script parses the numeric value within the unit, then, the unit is converted to the given statement (<strong>kW</strong> → <a href="https://www.wikidata.org/wiki/Q3320608" rel="nofollow noreferrer">kilowatt (<code>Q3320608</code>)</a>). However, the script throws error (it is a warning due I'm handling errors using try-except) when passing the unit as URL (entity helper string) as well as statement (QXXXXX):</p>
  
  <pre><code>WARNING: API error modification-failed: Illegal value: https://wikidata.org/wiki/Q79738
  Traceback (most recent call last):
    File "/mnt/c/Users/Davod/Documents/git/wikidata_top500/core/pywikibot/page.py", line 112, in handle
      func(self, *args, **kwargs)
    File "/mnt/c/Users/Davod/Documents/git/wikidata_top500/core/pywikibot/page.py", line 4325, in addClaim
      self.repo.addClaim(self, claim, bot=bot, **kwargs)
    File "/mnt/c/Users/Davod/Documents/git/wikidata_top500/core/pywikibot/site.py", line 1326, in callee
      return fn(self, *args, **kwargs)
    File "/mnt/c/Users/Davod/Documents/git/wikidata_top500/core/pywikibot/site.py", line 7946, in addClaim
      data = req.submit()
    File "/mnt/c/Users/Davod/Documents/git/wikidata_top500/core/pywikibot/data/api.py", line 2080, in submit
      raise APIError(**result['error'])
  pywikibot.data.api.APIError: modification-failed: Illegal value: https://wikidata.org/wiki/Q79738 [messages:[{'name': 'wikibase-validator-not-allowed', 'parameters': ['https://wikidata.org/wiki/Q79738'], 'html': {'*': 'Valor ilegal: &lt;a class="external free" href="https://wikidata.org/wiki/Q79738"&gt;https://wikidata.org/wiki/Q79738&lt;/a&gt;'}}]; help:See https://www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &amp;lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&amp;gt; for notice of API deprecations and breaking changes.]
  </code></pre>
  
  <p>I uploaded <a href="https://github.com/Amitie10g/wikidata_top500" rel="nofollow noreferrer">my project</a> to GitHub. Relevant source code is found at the <a href="https://github.com/Amitie10g/wikidata_top500/blob/python/functions.py#L89" rel="nofollow noreferrer"><code>addClaim()</code> function</a>, <a href="https://github.com/Amitie10g/wikidata_top500/blob/python/functions.py#L109" rel="nofollow noreferrer">line 109</a>.</p>