Loomio

API Issues

RG Rob Guthrie Public Seen by 85

Hi Shauna, I thought I'd start the thread to ask what issues you're experiencing with the API. Thanks for giving it a go. I'm keen to improve it based on feedback, and I love the metagov project.

SG

Shauna Gordon-McKeon Wed 9 Feb 2022 12:41AM

Hi Rob, thanks for the quick response! I'm trying to start a new vote on an existing thread in a subgroup, using the recipient_user_ids parameter listed here https://www.loomio.org/help/api?api_key=xThe to notify/invite everyone in the subgroup that the thread is in. But I'm the only one getting an email invite or showing up as invited in the vote. (The account doing the invite is a separate bot account, so as far as I can tell there's no reason for me to be special and get the invite, except that I'm an admin.)

SG

Shauna Gordon-McKeon Mon 14 Feb 2022 5:53PM

Hi @Rob Guthrie, any thoughts on what could be going wrong here?

RG

Rob Guthrie Wed 16 Feb 2022 3:33AM

Hi @Shauna Gordon-McKeon, so sorry I did not see your first reply.

I've updated the API documentation, so the examples all work when you paste them into your terminal. I've tested the updated create poll example and it does send email notifications out. Please give it a go and let me know how you get on.

Good luck, and thank you!

SG

Shauna Gordon-McKeon Fri 11 Mar 2022 7:37PM

This example from the page doesn't work for me: curl -d 'api_key=$APIKEY' https://www.loomio.org/api/b1/memberships

SG

Shauna Gordon-McKeon Fri 11 Mar 2022 7:48PM

I tried to use the examples from your docs:

curl -X POST -H 'Content-Type: application/json' -d '{"title":"example thread with invites", "recipient_user_ids": [633215], "api_key": $APIKEY}' https://www.loomio.org/api/b1/discussions

This created a thread but did not email me a notification or invite me to the thread as far as I can see. The thread is here: https://www.loomio.org/d/08V2g3Eq/example-thread-with-invites

RG

Rob Guthrie Tue 15 Mar 2022 12:07PM

Damn, I'm so sorry, @Shauna Gordon-McKeon

I was sure that was working, wow, how strange. I've had a look and confirmed it does send notifications. I'll try to fix this tomorrow.

SG

Shauna Gordon-McKeon Mon 21 Mar 2022 3:31PM

Were you able to figure out what's going on? If not, maybe we could do a videocall and try to work this out synchronously?

RG

Rob Guthrie Wed 6 Apr 2022 3:52AM

Hi Shauna, I've fixed this issue just now. It's taken a long time just because I had to a large branch to finish first - I'm sorry to leave you hanging!

Both discussion and poll examples in the documentation page work correctly for me now. I hope this works for you and is still relevant :)

RG

Rob Guthrie Wed 6 Apr 2022 3:59AM

Oh, I should mention: I've updated the poll results format.

There is now a poll.results array, with all the results neatly calculated. I'd be happy to have a call if you want to discuss how you're using the API, or have any other questions.

SG

Shauna Gordon-McKeon Wed 6 Apr 2022 4:19PM

We did some debugging of our own last week and finally discovered that adding a [] to recipient_emails and recipient_user_ids (ie "recipient_emails[]": [x,y,z]) fixed the issue.

It was a pain to figure out for two reasons:

1) the notifications weren't never working - they did send to the last person in the list. until we figured that out, the pattern of "this works! no wait it doesn't!" was very confusing.

2) the issue only arises when we send the call from our code, not when we use CURL

We were surprised to discover that adding [] fixed the issue, since we thought that was deprecated syntax and is no longer in your docs. Our code was calling requests.post(url, data), without specifying that the data ought to be json, so we suspect that we were sending it as form data. And that your API is for some reason handling form data differently than json data.

Anyway, we're more or less okay on our end. Just wanted to pass that info along so you can clarify the json/form data distinction (if possible).

RG

Rob Guthrie Fri 8 Apr 2022 3:53AM

Nice work. I changed the documentation examples to use json rather than form data last time I did a big update. It just looks so much simpler to me.

It's rails code, not Loomio code, that parses the json or form data and presents me with just a "params" object. So this aspect of parsing the incoming data has likely not changed recently.

The array[] thing is something php introduced, I think. You're supposed to use it like array[]=1&array[]=2&array[]=3 to send array=[1,2,3].

Anyway, I'm so sorry you had issues and I took a long time to respond. I am committed to improving the API with the feedback I get. So please let me know if there is something I can do. With a little time, I'm sure I can help.

RG

Rob Guthrie Fri 8 Apr 2022 3:54AM

Have you seen the new poll.results data format? Is that useful for you?

SG

Shauna Gordon-McKeon Thu 28 Apr 2022 4:53PM

Sorry, still focused on trying to get the existing feature working. I was able to get the notifications to work, but when they started working, the actual interface for voting disappeared. Do you have any idea what's going on? I didn't change anything else that I'm aware of.

https://www.loomio.org/d/GmUcr8ab/expense-submissions-gateway-/40

RG

Rob Guthrie Fri 29 Apr 2022 12:48AM

Could you send me a video of this? I've just tested it and it seems to work properly. We did have this bug reported 2 weeks ago, but I've since fixed it (or so I thought).

SG

Shauna Gordon-McKeon Fri 29 Apr 2022 1:03AM

Ack, sorry - pretty sure it was an issue on our end. I meant to update this thread but forgot. I'll let you know if the fix I found for it stops working!

RG

Rob Guthrie Fri 29 Apr 2022 1:04AM

Ok no problem.