Forum Discussion

djondinium's avatar
9 months ago

restBuilder with search endpoint to return messages with admin privileges?

Hi,

When I call

<#assign comments = restBuilder().method("POST").path("/search").body(query).admin(true).call()>

where

<#assign query = {
  "messages": {
    "fields": [ "id", "subject", "author.id", "author.first_name", "author.last_name" ],
    "sorts": [ "post_time DESC" ],
    "constraints": [ { "parent.id": '${messageId}', "board.id": "${nodeId}" } ],
    "limit": 20
  }
}>

 

I'm not getting author.first and last name even while making the call as an admin. The first and last name are only visible if user is an admin or has elevated access, all other users will not see the names.

Does anyone know why? Is the admin(boolean) method broken in general or just for the search endpoint?

Thanks!

  • Hi djondinium 

    I tried it and it seems to be working for me. I copied your code (minus sorts and constraints) and tested it in stage with a normal non-admin user and I could see the names.

    <#assign query = {
      "messages": {
        "fields": [ "id", "subject", "author.id", "author.first_name", "author.last_name" ]
      }
    }>
    
    <#assign comments = restBuilder().method("POST").path("/search").body(query).admin(true).call()>
    
    <#list comments.data.items as message>
        <p>
            ${message.subject} by ${message.author.first_name!"missing"} ${message.author.last_name!"missing"}
        </p>
    </#list>

     

    Here is what I see with a regular account. Maybe ask support.

     

     

    • djondinium's avatar
      djondinium
      Expert

      Thanks for the help, Akenefick !

      I created a ticket with support to check on the issue.

      I tried many different ways to make this work, but all efforts were unsuccessful. Having something wrong with the platform is probably what's causing it.