Unable To Get Data Through API

I tried to fetch data from ERPNext using GET Method on http endpoint /api/resource/{Doctype} on Postman. However I achieved status: 403 Forbidden.
I understand it has something to do with user login credentials (authorization or password). It would be very helpful if someone could provide the steps to resolve this issue. Also where can I find the required credentials inside the /home/frappe/frappe-bench folder required to fetch data through the API.

Thank You.

Here’s a “simple as possible” curl call, generated by Postman but then trimmed down to the essentials, that shows what you need:

curl -L 'https://dev.yourpublic.work/api/resource/Territory/' -H 'Authorization: token ec226d15b52879e:ca6deade2ff3d0e'
1 Like

You need to correct the settings in API Access for the user that will be placing the API calls:

In my case Administrator places those calls, so :

Note that when you click the [Generate Key] button, that user’s database record is updated immediately, such that if you then hit the [Save] button it will report that the record was updated after you first loaded it. Ignore that.

Copy and paste the API Secret into Postman when the popup dialog appears, then simply reload the page to get the API Key.

Postman allows working with variables, in case you were unaware, so my Authorization headers section looks like this:

My ENToken variable looks like this :

ENToken ec226d15b52879e:ca6deade2ff3d0e

Thank you for your valuable inputs. I will try this out once.

It worked. Thank You so much !

That pleases me. Glad to hear it. Thank you for letting me know.

(At the foot of my answer you’ll find a “solution” button. Please click it, to let others in future know that your question was answered correctly.)

1 Like