files/en-us/web/api/mediakeysession/generaterequest/index.md
{{APIRef("Encrypted Media Extensions")}}{{SecureContext_Header}}
The generateRequest() method of the {{domxref('MediaKeySession')}} interface returns a {{jsxref('Promise')}} after generating a license request based on initialization data.
generateRequest(initDataType, initData)
initDataType
initData
initDataType. It is an instance of any of the following types:
A {{jsxref('Promise')}}.
initDataType is an empty string, if initData is an empty array, or if the provided initData is not valid according to the specified initDataType.NotSupportedError {{domxref("DOMException")}}
MediaKeySession object does not support the provided initDataType, if the sanitized initialization data is empty, or if the sanitized initialization data is not supported by the content decryption module (CDM).InvalidStateError {{domxref("DOMException")}}
MediaKeySession object is in a closing or closed state, or if it has already been initialized.{{Specifications}}
{{Compat}}