# anonymize problems

**URL:** <https://discourse.orthanc-server.org/t/anonymize-problems/413>\
**Category:** Google Groups archive\
**Created:** [April 29, 2016, 1:38pm UTC](https://discourse.orthanc-server.org/t/anonymize-problems/413 "2016-04-29T13:38:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_van\_Ommen](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/r/d26b3c/32.png) [@Robert\_van\_Ommen](https://discourse.orthanc-server.org/u/Robert_van_Ommen)\
**Post date:** [April 29, 2016, 1:38pm UTC](https://discourse.orthanc-server.org/t/anonymize-problems/413/1 "2016-04-29T13:38:24Z")

</div>

I can’t get anonymisation to work If I put it in a lua file:

`function OnStableStudy(studyId, tags, metadata) local command = {} local modified = RestApiPost('/studies/' .. studyId .. '/anonymize', DumpJson(command)) end`

I always get: Lua: Error in RestApiPost() for URI: /studies/747fc6c6-bd2a6043-b56cf4e3-6c186911-2f25bced/anonymize

it’s probably my lua inexperience 🙂 can anybody help?

---

<div class="post-metadata">

**Author:** ![Robert\_van\_Ommen](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/r/d26b3c/32.png) [@Robert\_van\_Ommen](https://discourse.orthanc-server.org/u/Robert_van_Ommen)\
**Post date:** [April 29, 2016, 5:12pm UTC](https://discourse.orthanc-server.org/t/anonymize-problems/413/2 "2016-04-29T17:12:49Z")

</div>

oh btw i can anonymize the study without a problem if i use curl it’s just something i can’t get right in my lua. There should be {} in the raw post body but if i dump the command to string i see []

---

<div class="post-metadata">

**Author:** ![Robert\_van\_Ommen](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/r/d26b3c/32.png) [@Robert\_van\_Ommen](https://discourse.orthanc-server.org/u/Robert_van_Ommen)\
**Post date:** [May 9, 2016, 1:43pm UTC](https://discourse.orthanc-server.org/t/anonymize-problems/413/3 "2016-05-09T13:43:04Z")

</div>

Answering my own question:

Like this it does work:

`

– tags to keep during anonymization  
local keep = {‘StudyDescription’, ‘SeriesDescription’}  
function OnStableStudy(studyId, tags, metadata)  
if (metadata[‘ModifiedFrom’] == nil and metadata[‘AnonymizedFrom’] == nil) then

– tags to keep during anonymization  
local keep = {‘StudyDescription’, ‘SeriesDescription’}

– anonimyze the study  
local command = {}  
command[‘Keep’] = keep  
local modified = ParseJson(RestApiPost(‘/studies/’ … studyId … ‘/anonymize’, DumpJson(command)))

end  
end  
`
