0

I have a python script which uses flask_restful and have queries different services via REST 3 times with in a script and all the 3 REST queries are sequential and there is a data dependency. We use the JSON response object of the first rest query to build the json request for the next one. The python script works perfectly fine when run in my local machine and when moved to the docker container and run. The script fails with an error saying "No JSON object could be decoded" from the response object of the first JSON query.

from flask_restful import Api, request
import json
import requests

resp = requests.post(url=url,data=dat,headers=headers)
json_data = json.loads(resp.content)

resp.content throws

raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

But the same script works when run locally. Thank you. Any help would be much appreciated. Thanks

vijay krishna
  • 263
  • 1
  • 3
  • 14
  • This means you have "forgottent" to add some component, Python library or anything in your Dockerfile – user2915097 Dec 14 '16 at 13:18
  • Does the response have any information at all? Try looking at the content without `json.loads` there may be a useful error message there. I would also review the container's network configuration and confirm it's properly networked such that it can reach the required resources. – sytech Dec 14 '16 at 13:21
  • @user2915097: I included flask and requests but did not include json. Does json library come as a built in with python? – vijay krishna Dec 14 '16 at 13:32
  • Yes json is included, and you do not have a `ImportError...` after the line `import json` – user2915097 Dec 14 '16 at 13:36
  • @user2915097: So I hope the dependencies are right. I am not using any other library other than the mentioned – vijay krishna Dec 14 '16 at 13:40
  • I tested the docker image locally and the script works just fine even with the docker but fails when run this image in marathon, a container orchestration platform – vijay krishna Dec 14 '16 at 15:21
  • There was so access issue within the network. Thank you for the comments ***Resolved*** – vijay krishna Dec 14 '16 at 16:49

0 Answers0