I am getting error "A JSON text must at least contain two octets!" while performing api execution.For Success 200 response code i am getting proper json format.But 404 error i am getting below response which is empty string.Can anyone help how to handle this error?.
Response
"404"
""
"RESPONSE_TIME = 1.96193"
"Encoding = UTF-8"
""
Threw an exception inside create Controller.getparameter() A JSON text must at least contain two octets!
Rails Controller code
if OpetationType == "Get"
client = Client.new
response = client.get_call(macaddress, parameter)
redis_client = Redis.new
access_token = redis_client["Token"]
response_time = client.response_time
p "RESPONSE_TIME = #{response_time}"
p "Encoding = #{response.body.encoding}"
response.body.force_encoding("ISO-8859-1").encode("UTF-8")
p response.body
result_hash["response"].push({"macaddress": macaddress, "body":
JSON.parse(response.body), "response_time": response_time.to_s})
result_hash["status"].push("#{response.code}")
end
Aucun commentaire:
Enregistrer un commentaire