Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Jonny Pelter Posted July 21, 2021 Posted July 21, 2021 I'm attempting to use the REST API to have a member follow a forum topic, using the API found here: https://invisioncommunity.com/developers/rest-api?endpoint=core/members/POSTitem_follows As part of my integration tests, I am successfully able to create a member and a topic. I'm now attempting to have the member follow the topic, but I'm receiving errors. Ultimately, the URL I'm posting to would look something like this: https://community.justaskmax.com/api/core/members/421/follows?followApp=forums&followArea=topic&followId=543&followAnon=false&followNotify=true&followType=immediate The parameters I'm using are: followApp: forums followArea: topic followId: <the id of the topic that was created> followAnon: false followNotify: true followType: immediate The member id in the /core/members/{id}/follows would be the id of the user that was created. However, this results in the following error: { "errorCode": "2C292\/J", "errorMessage": "INVALID_CONTENT" } The error suggests that the topic I'm trying to follow doesn't exist. However, I'm verifying the topic's existence using its id before attempting to follow, and the API tells me that the topic does indeed exist. This error is also returned if I try to add an already existing member to an already existing topic (and also an existing member to a newly created topic). I'm able to list the follows for members, and it looks like my followApp and followArea parameters are correct. For example, a call to https://community.justaskmax.com/api/core/members/1/follows returns: { "followKey": "43562d4ff4258514985f03acfdedf436", "followApp": "forums", "followArea": "topic", "followId": 99, "followAnon": false, "followNotify": true, "followType": "immediate", "followSent": null, "followName": "parental don't work on Xbox", "followUrl": "https:\/\/community.justaskmax.com\/topic\/99-parental-dont-work-on-xbox\/" } Everything therefore looks correct for what I'm attempting to do, but I'm unable to figure out why I'm getting the error. Any ideas?
Daniel F Posted July 21, 2021 Posted July 21, 2021 Thanks, I have filled a bug report for this. (At a quick glance it seems that there's a typo in the used request variables - followApp vs follow_app )
Jonny Pelter Posted July 22, 2021 Author Posted July 22, 2021 Thanks @Daniel F I tried changing the parameter followApp to follow_app: https://community.justaskmax.com/api/core/members/421/follows?follow_app=forums&followArea=topic&followId=543&followAnon=false&followNotify=true&followType=immediate but the same INVALID_CONTENT error is returned. I also tried some changing all the parameters to underscore variations: https://community.justaskmax.com/api/core/members/421/follows?follow_app=forums&follow_area=topic&follow_id=543&follow_anon=false&follow_notify=true&follow_type=immediate without any success (with and without the optional parameters - followAnon, followNotify, and followType). Something else I tried was having a user unfollow a topic via the website, then using the API to have them re-follow the topic. However, the INVALID content error was also returned in this case. Are "forums" and "topic" correct for the followApp and followArea parameters? Is there maybe a new required parameter that was introduced that I'm not sending across?
Daniel F Posted July 22, 2021 Posted July 22, 2021 Yes the endpoint is correct. The fix is to change Request::I()->follow_app to Request::I()->followApp !
Jonny Pelter Posted July 22, 2021 Author Posted July 22, 2021 Hi, Changing followApp to follow_app didn't fix the issue. However, I've discovered that sending both follow_app and followApp with the same value does work: [POST] https://community.justaskmax.com/api/core/members/421/follows?followApp=forums&follow_app=forums&followArea=topic&followId=543&followAnon=0&followNotify=1&followType=immediate Leaving out either follow_app or followApp results in the INVALID_CONTENT message. I also found that followAnon and followNotify say they expect a bool. I was passing "true" and "false" to these, but it seems that either 1 or 0 is expected, to indicate true or false. Using "true" or "false" results in "false" being returned for followAnon and followNotify, and followType remains null. With these changes, it appears I can now follow topics. So all working now but does maybe appear to be a small bug (needing to send both follow_app and followApp with the same value) perhaps. Thanks for all your help!
Daniel F Posted July 22, 2021 Posted July 22, 2021 8 minutes ago, Jonny Pelter said: Changing followApp to follow_app didn't fix the issue. Look at my reply again;) Quote The fix is to change Request::I()->follow_app to Request::I()->followApp !
Jonny Pelter Posted July 22, 2021 Author Posted July 22, 2021 sorry Daniel, we've now got it working we think, thanks for all your help! 🙂
Recommended Posts