Resume the print after pausing using octoprint api

What is the problem?

I am trying to use octoprint through a Python code rather than the web interface. I am referring following links: GitHub - Ignisleo/OctoprintPythonAPI: Python API for the OctoPrint 3d printer server and REST API β€” OctoPrint master documentation. The codes work fine, start, pause and stop commands work fine. the problem comes when I pause the printing and then try to resume it. sometimes it gives response 409 error and sometimes response 400 error. how to resume printing? please guide.

What did you already try to solve it?

I have added the "resume" action in octoprint_api.py as suggested in REST API β€” OctoPrint master documentation site and then executed the command however it is not working.

Have you tried running in safe mode?

WRITE HERE

Did running in safe mode solve the problem?

WRITE HERE

Systeminfo Bundle

You can download this in OctoPrint's System Information dialog ... no bundle, no support!)

WRITE HERE

Additional information about your setup

OctoPrint version, OctoPi version, printer, firmware, browser, operating system, ... as much data as possible

I took octoprint_api file then used printer.py file to execute the commands in command terminal as well as script file. however it is not working. i event kept time delay between pausing and resuming action.