TabPy: Python returning Json into Tableau, “Error Parsing Number”

I am trying to use Tableau calculated field to use my python script, which gets JSON data. My ultimate goal is to get this data into tableau in a tabular format.

I have read JSON is easier to get into tableau as opposed to dataframe object.

I currently use it in Spyder program. and execute this to get my data.

Code [ print (get1D (“2019-02-02”, “2019-02-05”, “Tableau”, “Limits”)) ]

In my calculated field I get the error: “Error Parsing Number” on

Code [ .format(status_code)) ]

error msg:

Any help would be appreciated on getting this data into tableau. Here is my full script.

Code[ SCRIPT_INT(

import time

import requests

import json

import pandas as pd

import re

import urllib3

import math

from io import StringIO

from datetime import datetime, date,timedelta

from pandas.tseries.offsets import BDay

from urllib.parse import urlencode

from flask import json

def call_api(url, request_dict, post):

if post:  

    header = {'content-type':'application/json'}  

    resp = requests.post(url, data=json.dumps(request_dict), auth=('user', 'pass'), headers = header, verify=False)  

else:  

    url = url + urlencode(request_dict)  

    resp = requests.get(url, auth=('user', 'pass'), verify=False)  

status_code = resp.status_code  

if status_code == 401:  

    raise ValueError("There is an error with the connection.

Login failed.
Not authorized. Please check your credentials and try again.
Status code {}".format(status_code))

elif status_code == 404:  

    raise ValueError("There is an error with the connection.

Could not connect to the server.
Status code {}".format(status_code))

elif status_code == 200:  

    pass  

else:  

    raise ValueError("There is an error with the connection.

Status code {}".format(status_code))

return resp  

def getData (startDate, endDate, nodeName, Type, Id):

request_dict = [{  

    "hierarchy": "Tableau",  

    "nodeName": nodeName,  

    "FilterId": Type,  

    "Id": Id ,  

}]  

url = "https://sampleurl/startDate={0}&endDate={1}"   

startDate = datetime.strptime(startDate, '%Y-%m-%d')  

startDate = startDate.strftime ('%Y%m%d')  

endDate = datetime.strptime(endDate, '%Y-%m-%d')  

endDate = endDate.strftime ('%Y%m%d')  

url = url.format(startDate, endDate)  

resp = call_api(url, request_dict, True)   

return resp.json ()  

def get1D(startDate, endDate, nodeName, Type):

return getData (startDate, endDate, nodeName, Type, 1)  

) ]