Dear Meng,
Thank you for your answer.
Yes you have to lock the adom, make your changes and the commit the changes and then unlock the adom. This must be done in the script so that you don't hit the error.
Even if you do not see it locked in the GUI, if you run your script that does not contain the lock of adom before doing changes, it will return the same error code.
When you are saying:
Or even I locked it manually from GUI using same id, the result is the same.
Are you using same session id as the script while the script is running, or am I missing something? Because the lock must be done using the same session id, but after the login call and before the add function calls.
Also I adapted, your sample to add the "schedule" data parameter that is mandatory to add_firewall_policy and removed the "type" data parameter that was not correctly understood in you add_firewall_address.
When adding the lock_adom(), commit_changes() and unlock_adom() in the code, it does not trigger the error, if we omit them it triggers the errors, in my environment.
I presume the lock is not on the policy package itself because as I understand even adding an address does not work for you.
Also it may not be an locking issue, in case of admin user account not having sufficient privilege it would trigger an error code -11 "No permission for the resource", in case of no JSON API Access Read-Write, or not being allowed to all Administrative Domains, or not sufficient "Admin profile". So it should not be your case.
Nevertheless, please find in attachment your script modified to take into account the lock, commit and unlock steps.
Maybe you can share the output of your script so I can better help you?