403 forbidden error on calling jenkins post api from python script
As recommended by Jenkins (&gt;2.2xx) you may benefit by creating an API token for the user, I did so, to trigger Jenkins job in my local Jenkins server from NODEJS code.
Please refer below for further clarification:

https://www.jenkins.io/doc/book/system-administration/authenticating-scripted-clients/#shell-with-curl
https://www.jenkins.io/doc/book/using/remote-access-api/#RemoteaccessAPI-CSRFProtection

And for details: https://www.jenkins.io/doc/book/managing/security/