Forum Discussion
Tried that format, same result.
The error returned, if it's helpful:
{
"status":"error",
"message":"Membership Request not found.",
"data": {
"type":"error_data",
"code":505,
"developer_message":"",
"more_info":""
},
"metadata":{}
}
Making the same call using restBuilder:
<#assign approve = restBuilder()
.method("PUT")
.path("/nodes/grouphub:" + node + "/membership_requests")
.body({ "data" : {
"type": "membership_request",
"approve_request": "true",
"user_id": uid
} })
.admin(true) />
<#assign resp = approve.call() />
I get the dreaded Freemarker error dump with this being the only potentially meaningful error:
Caused by: freemarker.template.TemplateModelException: unexpected exception during rest call: FreemarkerRestCall{version='2.0', restCall=RestCall{path=[nodes, grouphub:myCommunity, membership_requests], action=PUT}, adminCall=true, impersonationParameterSource=null}
On my page quilt, it says "Widget cannot be displayed."
Well, I figured out what the issue was.
On a lark, I tried a raw API call with curl, which actually worked:
phoneboy-cli:~ $ curl -u mystageuser:mystagepass -X PUT https://mystageurl/api/2.0/nodes/grouphub:myGroupHub/membership_requests -H 'Content-Type: application/json' -H 'li-api-session-key: mysessiontoken' -d '{ "data": { "type": "membership_request", "approve_request": true, "user_id": 226 } } '
That helped me figure out uid was being interpreted as a string versus a number, which is what the API expects.
Somehow, I thought putting ?c would resolve this, but instead I need to replace that with ?number.
Note this still doesn't solve the issue with restBuilder, which crashes even with the above change.
That said, I at least have a working solution now.
I really wish the Community API gave more meaningful error messages.
Most of the ones I've encountered have been...terribly unhelpful.
Related Content
- 5 months ago
- 30 days ago
- 3 years ago
- 8 months ago