Set an encrypted field through the REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2018 11:10 AM
Hi,
I'm trying to do a a PUT the Table rest endpoint as described in:
https://developer.servicenow.com/app.do#!/rest_api_doc?v=jakarta&id=r_TableAPI-PUT
so that I can set the value of an encrypted field. I'm setting the parameter "sysparm_input_display_value" to true as described in the docs, but it's not persisting the value to the field. My API user does have a role that has an encryption context. But how do you even pick which encryption context to use for your API user when submitting requests? If you have multiple encryption context roles on your user, how would the API determine which one to use to encrypt the field value?
The documentation states:
"To set the value of an encrypted field, you must set this parameter (sysparm_input_display_value) to true. If this parameter is not set to true, values submitted to encrypted fields are not saved. Additionally, the requesting user must have the appropriate encryption context prior to submitting the request."
How does your user (which you are using to submit requests to the API) obtain the "appropriate encryption context"? In the UI you can have the encryption context dropdown where you can select, but how do you do that for an API submission?
I have seen some posts pointing to GlideRecord / GlideEncryptor scripts where you can in that scritpting world get and set the contextID, but those scripting approaches are not helpful to me as I'm submitting the API requests from a .NET console application.
What am I missing? Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2018 09:27 PM
That's interesting Taj.
A couple of thoughts that may be helpful:
a) try using Patch instead of Put
b) if that doesn't fix it, the best approach may be to open a Hi ticket since it doesn't make much sense will the value will appear but it will not persist.
Thanks,Berny