IBM Support

Scheduled Jupyter Notebook fails with POST /bi/v1/jupyter/schedule returned unexpected HTTP status code: 400

Troubleshooting


Problem

A scheduled Jupyter Notebook fails with error:
POST /bi/v1/jupyter/schedule returned unexpected HTTP status code: 400

Symptom

1) Schedule shows status: Failed
2) Run History Details show error stack:
restBridgeService request has failed. Caused by: com.ibm.bi.rest.bridge.exception.RestBridgeRuntimeException: POST /bi/v1/jupyter/schedule returned unexpected HTTP status code: 400 at com.ibm.bi.rest.bridge.methods.RunMethod.restRun(RunMethod.java:279) at com.ibm.bi.rest.bridge.methods.RunMethod.processingLoop(RunMethod.java:159) at com.ibm.bi.rest.bridge.methods.RunMethod.execute(RunMethod.java:145) at com.ibm.bi.rest.bridge.service.RestBridgeAsyncService.invoke(RestBridgeAsyncService.java:115) at com.cognos.pogo.async.impl.AsyncContextImpl.invokeService(AsyncContextImpl.java:161) at com.cognos.pogo.async.impl.AsyncContextImpl.runRequest(AsyncContextImpl.java:125) at com.cognos.pogo.async.impl.AsyncRequestThread.safeRun(AsyncRequestThread.java:44) at com.cognos.pogo.util.threads.SafeThread.run(SafeThread.java:61)

Cause

An unhandled exception exists within the Jupyter Notebook
Product changes following 11.1.7 FP4 result in a requirement that the notebook not have unhandled exceptions.

Environment

Cognos Analytics with Jupyter Notebooks 11.1.7 FP5
Cognos Analytics with Jupyter Notebooks 11.1.7 FP6
Cognos Analytics with Jupyter Notebooks 11.2.4
Platform independent

Diagnosing The Problem

1) Open the notebook
2) Run each block of code
3) Look for unhandled exceptions, for example:
image-20230124154650-2

Resolving The Problem

Ensure that all code is written with appropriate exception handling (try/except, if/then/else, and so on).  For example:
Broken code:
def divide(x, y):
    
        result = x // y
        print("Your answer is :", result)
    
 
divide(3, 0)
Code with error handling:
def divide(x, y):
    try:
        result = x // y
        print("Your answer is :", result)
    except ZeroDivisionError:
        print("Sorry ! You are dividing by zero ")
 
divide(3, 0)
With error handling in place, the notebook will run successfully when scheduled

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSTSF6","label":"IBM Cognos Analytics"},"ARM Category":[{"code":"a8m0z000000GpAVAA0","label":"Jupyter Notebook"}],"ARM Case Number":"TS011595412","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"11.1.7;11.2.4;and future releases"}]

Document Information

Modified date:
24 January 2023

UID

ibm16857233