Failing to assign watchers to a ticket

pm (at zeit)'s Avatar

pm (at zeit)

04 Aug, 2016 03:13 PM

Hi there,

I've been using https://github.com/entp/lighthouse-api - gem for our Rails 4.2 application (Hint: I couldn't reply to this thread: http://help.lighthouseapp.com/discussions/api-developers/2079-is-there-a-ruby-gem-that-works-for-rails-42 - You might want to hit him up) but unfortunately assigning watchers doesn't seem to be covered by it.
Hence I tried my luck with doing it via a manual CURL request.
Here it is.

```
curl -X PUT \
   -H "X-LighthouseToken: API_KEY" \
   -F "ticket[body]=My Title" \
   -F "ticket[multiple_watchers][]=1" \
   -F "ticket[multiple_watchers][]=2" \
   -F "ticket[multiple_watchers][]=3" \
   https://ACCOUNT.lighthouseapp.com/projects/PROJECTID/tickets/NUMBER.xml
```

I of course have the ticket in question already created, the api-key as well as the ticket number, my accountname and the project-id are correct as well. Whenever I run this request, the frontend reports that I in fact updated the ticket with my title, however, suddenly NO user was assigned to the ticket anymore. The two watchers I wanted to add have the correct id as well.

// I forgot to add "[]" in after the field to show it includes more information.
Unfortunately now it only applies the very first user-id as watcher :/

// Alright, it further requires the field "multiple_watchers" to be defined as often as I want to assign watchers.. Guess I should've read up a little more on the curl-documentation.
Maybe, for the future, provide a small example like this in your documentations as well - Would've saved me a lot of time.
Still looking for a reply of your site, how I may improve this :)

Please, tell me how I can make this work :)

  1. Support Staff 1 Posted by Tiger Team on 09 Aug, 2016 02:52 PM

    Tiger Team's Avatar

    Hi, I'm looking at our code and it seems that should work, or just a string with comma-separated values like ticket[multiple_watchers]=1,2,3

  2. Support Staff 2 Posted by Tiger Team on 09 Aug, 2016 02:54 PM

    Tiger Team's Avatar

    Also, using multiple_watchers will reset all existing watchers and set it to whatever you send, so you'd want to get the current list of IDs and send those with your new list,

  3. 3 Posted by pm (at zeit) on 11 Aug, 2016 07:34 AM

    pm (at zeit)'s Avatar

    Hi,

    You're right that the watchers get overwritten with each request, but in this case that's on purpose. We generate a new ticket and in the "same" rush assign watchers to it (Basically we first CREATE and UPDATE afterwards).

    Thanks for your feedback. We got it working this way now :)

  4. brandi closed this discussion on 11 Aug, 2016 06:01 PM.

Discussions are closed to public comments.
If you need help with Lighthouse please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac