iarriola
8 years agoAce
GDPR personal_data resource only available on Lithium Studio API Browser
I'm trying to develop a custom endpoint at Lithium Studio, for exposing GDPR functionality described at GDPR Community API support. The query at API browser looks like this:
SELECT personal_data FROM users WHERE id='SOME_ID'
and it perfectly returns the desired data. Then moving that query to a custom endpoint looks like this:
<#compress>
<#assign error = "" />
<#assign userId = http.request.parameters.name.get("userId", "0") />
<#if (userId != "0")>
<#attempt>
<#assign query = "SELECT personal_data FROM users WHERE id='${userId}'"/>
<#assign resp = restadmin("2.0","/search?q=" + query?url)/>
${resp.status?json_string}
${apiv2.toJson(resp)}
<#if (resp.status == "success")>
<#assign userData = resp.data />
${apiv2.toJson(userData.items[0])}
<#else>
<#assign error = "there is no user with id " + userId?number?c />
${error?json_string}
</#if>
<#recover>
<#assign error = .error />
${error?json_string}
</#attempt>
<#else>
<#assign error = "userId parameter is required" />
${error?json_string}
</#if>
</#compress>After saving it and trying to access the endpoint at :
https://www.my.community.com/forum/s/TENANT_ID/plugins/custom/company/company/custom.user.personal_data?userId=SOME_ID
The result, returns an empty response, something like this:
{
"status" : "success",
"message" : "",
"http_code" : 200,
"data" : {
"type" : "users",
"list_item_type" : "user",
"size" : 1,
"items" : [ {
"type" : "user",
"personal_data" : {
"type" : "user",
"items" : [ ]
}
} ]
},
"metadata" : { }
}
{
"type" : "user",
"personal_data" : {
"type" : "user",
"items" : [ ]
}
}Can this be considered a bug?