Loomio

API Issues

RG Robert Guthrie Public Seen by 92

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

Robert 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

Robert 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

Robert 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

Robert 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).

Load More