Forum Discussion

smogger914's avatar
10 years ago

Java call not returning author.email, but the studio api browser does

I am doing an api call with a java client and executing the following query using api v2:

 

SELECT id, body, view_href, subject, author.email FROM messages WHERE replies.count(*) = 0 AND depth = 0

 

When I look at the author.email field it comes back empty. If I do the same query in the studio api browser the email is returned. Can anyone think of why this would happen? All the other values are coming back.

 

api browser:

{
"status" : "success",
"message" : "",
"http_code" : 200,
"data" : {
"type" : "messages",
"list_item_type" : "message",
"size" : 1,
"items" : [ {
"type" : "message",
"id" : "58",
"view_href" : "/t5/Welcome-Board/asdsada/m-p/58#M36",
"author" : {
"type" : "user",
"email" : "blah@blah.com"
},
"subject" : "asdsada",
"body" : "<P>asdasdasdasd</P>"
} ]
},
"metadata" : { }
}

 

java code:

{
   "metadata":{

   },
   "http_code":200,
   "data":{
      "size":1,
      "list_item_type":"message",
      "type":"messages",
      "items":[
         {
            "author":{
               "type":"user",
               "email":""
            },
            "subject":"asdsada",
            "id":"58",
            "href":"/messages/58",
            "type":"message",
            "body":"<P>asdasdasdasd<\/P>",
            "view_href":"http://stage-community.zuora.com/t5/Welcome-Board/asdsada/m-p/58#M36"
         }
      ]
   },
   "message":"",
   "status":"success"
}

6 Replies

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    10 years ago

    No idea smogger914

     

    But what happen in your Java client if you change your query to something less restrictive, e.g.: 

     

    SELECT * FROM messages WHERE replies.count(*) = 0 AND depth = 0

    Do you get the author email? 

  • smogger914's avatar
    smogger914
    Guide
    10 years ago

    OlivierS when I do the SELECT * query the author object doesn't have the email. It looks like this:

     

    "author" : {
    "type" : "user",
    "id" : "3",
    "href" : "/users/3",
    "view_href" : "/t5/user/viewprofilepage/user-id/3",
    "login" : "blah"
    },

     

    I did author.email hoping it would work because I wanted to avoid doing another query to get each authors email. Seems like I will have to...

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    10 years ago

    Just a thought here ... smogger914

     

    It might be a permission issue ... When you're using the API browser, you're logged as an administrator.

     

    When running your JAVA code, is your user authenticated as an Admin, or has he just the API privileges?

  • smogger914's avatar
    smogger914
    Guide
    10 years ago

    That it, I wasn't authenticated in the java side. Doing the recomended oauth approach for a server to server app isn't something I wanted to do. Similar to the concerns expressed in this post. I ended up having to switch to api v1. Thanks for the help OlivierS

  • smogger914's avatar
    smogger914
    Guide
    10 years ago

    @OlivierS just found this post. According to the docs the email is accessible to annonymous users. Is this just an error in the docs or I am doing something wrong?

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    10 years ago

    smogger914 the post you're mentioning is for the User resource. Your query is for the Message resource.  What's weird, is that the author.email isn't documented ...