You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been using callrestapi functions under sharedfunctions.py for multiple scenarios and it works fine when that functionality is running for the first time and returns results back and I extract the desired information to make it readable, however, when I re-running it, it's printing the error in JSON format in the console itself. It should return the value so that we can extract and format it properly to list the issues in a readable format.
Thanks,
Sarvesh
The text was updated successfully, but these errors were encountered:
If you see below code, under the condition "400 <= ret.status_code <=599", it's just print the result and in another scenario, it passes "result=ret.text".
# response error if status code between these numbers
if (400 <= ret.status_code <=599):
print(ret.text)
result=None
if stoponerror: sys.exit()
# return the result
else:
# is it json
try:
result=ret.json()
except:
# is it text
try:
result=ret.text
except:
result=None
print("NOTE: No result to print")
return result;
In my scenario, if there is no error, it ran perfectly fine. However, if there is an error in the process, it prints the error but doesn't pass on the result to the main function.
Ok, thanks I understand now. That is by design, if there is an error we print the error and we do return the result, but it is set to "None". But I see what you are saying it might be nice to return the error also to the calling program.
Hi,
I have been using callrestapi functions under sharedfunctions.py for multiple scenarios and it works fine when that functionality is running for the first time and returns results back and I extract the desired information to make it readable, however, when I re-running it, it's printing the error in JSON format in the console itself. It should return the value so that we can extract and format it properly to list the issues in a readable format.
Thanks,
Sarvesh
The text was updated successfully, but these errors were encountered: