Forum Discussion

perk's avatar
perk
Adept
10 years ago

Error in Lithium endpoint with zendesk

I have a endpoint that is making requests to zendesk to retrieve a user ID and then make a subsequent request using the user's organization_id

 

<#assign url_getUser = baseUrl + "users/me.json" />
<#assign response_getUser = http.client.request(url_getUser).header("Authorization", "Bearer "+ response.content.access_token).json().get() />
<#if response_getUser.hasError>
<@renderError error = response_getUser.error.message />
<#else>
<#assign org = response_getUser.content.user.organization_id />
</#if>
<#assign url_getTickets = baseUrl + "organizations/" + org + "/tickets.json" />
<#assign response_getTickets = http.client.request(url_getTickets).header("Authorization", "Bearer "+ response.content.access_token).json().get() />
<#if response_getTickets.hasError>
<@renderError error = response_getTickets.content + " ###error here 2"/>
<#else>

 

However, I keep getting an error: 

The following has evaluated to null or missing: ==> response_getUser.content.user.organization_id [in template "retrieve-org-zendesk.ftl" at line 23, column 40]

Line 23 points to:

<#assign org = response_getUser.content.user.organization_id />

However, the JSON object that is returned when making the first request (users/me.json) is :

{
   "user": {
      "id": 123,
      "url": "xx",
      "name": "xx",
      "email": "xx",
      "created_at": "xxx",
      "updated_at": "xxx",
      "time_zone": "xxx",
      "phone": null,
      "photo": null,
      "locale_id": 1,
      "locale": "en-US",
      "organization_id": 123456,
      "role": "admin",
      "verified": true,
      "external_id": null,
      "tags": [],
      "alias": "",
      "active": true,
      "shared": false,
      "shared_agent": false,
      "last_login_at": "xxx",
      "signature": "",
      "details": "",
      "notes": "",
      "custom_role_id": null,
      "moderator": true,
      "ticket_restriction": null,
      "only_private_comments": false,
      "restricted_agent": false,
      "suspended": false,
      "chat_only": false,
      "user_fields": {
         "access_granted": null,
         "admin": null,
         "agent_ooo": false
      },
      "authenticity_token": "XXX"
   }
}

 

Why am I unable to utilize the organization_id in the subsequent request?

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)

    perk

     

    Just a guess here. Have you tried:

     

    <#assign org = response_getUser.user.organization_id />

    instead of:

     

    <#assign org = response_getUser.content.user.organization_id />
    • perk's avatar
      perk
      Adept

      Good guess, but no it didn't work :(

       

      The following has evaluated to null or missing: ==> response_getUser.user [in template "retrieve-org-zendesk.ftl" at line 23, column 40]

      Is there a way to debug this? I don't know how to view what response_getUser is which can help figure out how to retrieve the values. I am not too familiar with how this freemarker template works that was built by Lithium for us. We don't have documentation on this too.