Not able to get the response from django rest api using requests.get() method

403 views Asked by At

I have created a Django Rest Application and exposed one service (To get the User List)

Now when I am trying to call thru curl request, I am able to get the User List.

curl -v -XGET -i 'http://XXX.XX.XX9.XX1:8000/ebxxx/api/users/'

But When I try to call it from another app using requests.get() method , I am getting 504 server error:

I am trying :

header = {"Content-type":"application/json"}

response = requests.get("http://XXX.XX.XX9.XX1:8000/ebxxx/api/users/", headers=header) 

Error:

"response , response<504>"

1

There are 1 answers

0
Sonu Gupta On BEST ANSWER

I got the issue, It was related to proxy settings.

Actually I am using two VMs (Both have different IPs) with two different micro services (First VM has User Registration service (Add User, Delete User, Get Users) and Second VM has a service to call the User Registration service using django rest framework).

Now VMs are working in a local area network with some network permissions, So I have to set the proxy range and then I have to start the server.

I am using below command for proxy setting before running the Django server:

export no_proxy='my IP/range'

Now it works fine.