tag:help.lighthouseapp.com,2008-09-20:/discussions/api-developers/1192-changing-importance-via-apiLighthouse: Discussion 2013-05-23T21:32:33Ztag:help.lighthouseapp.com,2008-09-20:Comment/269844712013-05-23T18:49:09Z2013-05-23T18:49:09ZChanging Importance via API<div><p>I cannot seem to modify ticket importance via the API. I'm using
the lighthouse-api 2.0 rubygem.</p>
<p>Here's an example:</p>
<pre>
<code>1.9.3p392 :021 > t = Lighthouse::Ticket.find 652, params: { project_id: 52600 }
=> #<Lighthouse::Ticket:0x007f9dbd4ff468 ...
1.9.3p392 :022 > t.importance
=> 2
1.9.3p392 :023 > t.importance = 1
=> 1
1.9.3p392 :024 > t.save!
=> true
1.9.3p392 :025 > t = Lighthouse::Ticket.find 652, params: { project_id: 52600 }
=> #<Lighthouse::Ticket:0x007f9dc180e100 ...
1.9.3p392 :026 > t.importance
=> 2</code>
</pre></div>John Wulfftag:help.lighthouseapp.com,2008-09-20:Comment/269844712013-05-23T19:45:19Z2013-05-23T19:45:19ZChanging Importance via API<div><p>John -</p>
<p>Are you using <a href=
"https://github.com/entp/lighthouse-api">https://github.com/entp/lighthouse-api</a>?
If not, the other isn't maintained by us and doesn't look like it's
been updated since 2010. Let us know and we'll continue
troubleshooting with you.</p>
<p>Thanks,<br>
Nicole</p></div>Nicoletag:help.lighthouseapp.com,2008-09-20:Comment/269844712013-05-23T20:13:00Z2013-05-23T20:13:00ZChanging Importance via API<div><p><a href=
"https://github.com/entp/lighthouse-api">https://github.com/entp/lighthouse-api</a>
and <a href=
"http://rubygems.org/gems/lighthouse-api">http://rubygems.org/gems/lighthouse-api</a>
being two different things is very confusing. It looks like the
difference between the original repo and the one your maintaining
isn't significant. <a href=
"https://github.com/entp/lighthouse-api/compare/Caged:master...master">
https://github.com/entp/lighthouse-api/compare/Caged:master...master</a></p>
<p>Anyway, I've switched to
<code>git://github.com/entp/lighthouse-api.git</code> instead of
what RubyGems thinks <code>lighthouse-api</code> is and I'm getting
the exact same behavior as demonstrated in the console paste in my
first message.</p>
<p>I've also tried using curl and minimal XML to isolate the
problem. Here's what I tried (I've omitted irrelevant portions of
the XML responses):</p>
<pre>
<code>~ $ curl -H 'X-LighthouseToken: XXX' https://orcasnet.lighthouseapp.com/projects/52600/tickets/652.xml
<?xml version="1.0" encoding="UTF-8"?>
<ticket>
<importance type="integer">2</importance>
~ $ curl -H 'X-LighthouseToken: XXX' -X PUT --data '<ticket><importance type="integer">1</importance></ticket>' https://orcasnet.lighthouseapp.com/projects/52600/tickets/652.xml
~ $ curl -H 'X-LighthouseToken: XXX' https://orcasnet.lighthouseapp.com/projects/52600/tickets/652.xml
<ticket>
<importance type="integer">2</importance></code>
</pre>
<p>This shows that the importance change is indeed not being
applied.</p>
<p>Thanks for your help, really appreciate it!</p></div>John Wulfftag:help.lighthouseapp.com,2008-09-20:Comment/269844712013-05-23T20:37:27Z2013-05-23T20:37:27ZChanging Importance via API<div><p>I've just noticed in your API documentation (<a href=
"http://help.lighthouseapp.com/kb/api/tickets">http://help.lighthouseapp.com/kb/api/tickets</a>)
it says you only support the following fields for ticket POST
(creation).<br></p>
<pre>
<code>title
body - follows the same formatting rules.
state - Can be any one of these: new, open, resolved, hold, invalid. Optional, set to open by default for new tickets.
assigned-user-id - optional
milestone-id - optional
tag - space or comma delimited list of tags</code>
</pre>
<p>Do you only support these fields for PUT (update) as well? That
may explain why importance changes are not taking.</p>
<p>I know we used to be able to set <code>priority</code> but I
think when <code>priority</code> was renamed to
<code>importance</code> we lost the ability to set
<code>importance</code> via the API.</p></div>John Wulfftag:help.lighthouseapp.com,2008-09-20:Comment/269844712013-05-23T21:11:55Z2013-05-23T21:12:13ZChanging Importance via API<div><p>Hi John,</p>
<p>There is a significant difference between <a href=
"https://github.com/Caged/lighthouse-api">Caged</a> and <a href=
"https://github.com/entp/lighthouse-api">entp</a>:</p>
<pre>
<code>+ self.format = :xml</code>
</pre>
<p>That sets the content type to XML. The Caged version will send
XML but it will be interpreted as text, and so won't work.</p>
<p>Regarding the <code>importance</code> field, if you are using
the gem, you can use <code>priority</code> instead: it will set the
importance. If you are using curl, using <code>importance</code>
directly will work. Your example failed because you didn't send a
content type of XML.</p>
<p>Let me know how it goes with these changes.</p></div>Julientag:help.lighthouseapp.com,2008-09-20:Comment/269844712013-05-23T21:13:06Z2013-05-23T21:13:06ZChanging Importance via API<div><p>Well! It looks like reverting back to priority for PUT and POST
purposes has fixed things. We still need to use the new importance
field for properly "reading"</p>
<p>Thanks Julien!</p></div>John Wulff