I will not be able to share the whole code.
But I can share the idea.
We are setting up the context through Python ZAP api using the below method
zap.context.import_context(contextfile=context_Path, apikey=api)
Then in the same context before starting the scan, we try to add the alert filter using the below method(the parameters are the same except for the URL & api key)
zap.alertFilter.add_alert_filter(contextid='9',
ruleid= 10003,
newlevel='-1', # marking as False Positive
url='
http://localhost:75/sampleweb',
parameter= '',
attack= '',
evidence='',
enabled='1',
apikey=zap_generated_api_key,
urlisregex=False,
parameterisregex=False,
attackisregex=False,
evidenceisregex=False)
This method return ok as result
Then I am trying to call the below two methods
zap.alertFilter.test_context(apikey=api) --> internal_error
zap.alertFilter.apply_context(apikey=api) --> internal_error
I am expecting that an alert should be added as a false positive in Alert Tab once I call zap.alertFilter.apply_context