Response from external url failed

@Ryan1 share the error messages. and why don’t you use python to get api responses ?

Screenshot from 2023-09-01 14-17-46

Need at client’s end so not called the response using python. @bahaou

@Ryan1
image
I just tried your code and it works . so I am guessing the problem is the api authentication as your readystate indicates 4. are you sure about the url and the authentication in the header ? have you tried postman to test it ? try to remove the datatype . it was giving errors in my case .

Can you get a response from any random site other than erpnext? @bahaou

@Ryan1 yes, but test it using postman first.

It works in postman but not in erpnext custom script. @bahaou

@Ryan1 show the headers section


@bahaou

@Ryan1 what is the authorization field you wrote in the header of the call ? because I can’t see it in postman .

Authorization is not needed actually, the site ‘http://localhost:5000’ (running in flask, not a part of erpnext) simply throws value 220 which I need to fetch in erpnext doc. @bahaou

then remove it , and remove the datatype , it’s not json in your case

Screenshot from 2023-09-01 16-15-12

Then it throws this error CORS with fail response. @bahaou

@Ryan1 try datatype json . without header

Screenshot from 2023-09-01 16-21-07

Tried …same problem @bahaou

@Ryan1 try to add this header

 headers: {  'Access-Control-Allow-Origin': 'http://The web site allowed to access' },

same error @bahaou

@Ryan1 I really can’t do much more about this . just write python code and use js to call that python code. that would work better anyways .

@bahaou Cannot write python code as server side customization cannot be done for the client…anyways thanks :slight_smile:

check if “allow_cors” works for you Configuration

Tried earlier…not works! same CORS problem eventhough put it in common site config and site config. @revant_one