API Help Please Pt. 2

So, from my first post, I was able to get a response with the below…

ubuntu@ubuntuerp:~$ curl -k  https://site1.localhost/api/method/frappe.auth.get_logged_user -H "Authorization: token 59531e311365034:2b3836d48725b83"
{"message":"Administrator"}

In an API client called Insomnia, I also get the same message but I also get a bunch of cookies…

image

Why does it say guest and system user = no, and guest for full name and guest for user id, etc.?

How do I do the next part, in Insomnia and actually pull down some documents? Are the cookies automatically used, do I have to add the authentication header to the get request against /api/resource/:doctype? Is “:doctype” a real value or a placeholder?

I’m getting permission denied errors and (403 Forbidden)…an example when I tried /api/resource/Project…

and does not exist errors for :doctype…

(I guess I can only upload 1 picture)

Thanks in advance!

Hi:

:doctype is a placeholder, your second request url is ok.

  1. Has your user permissions for Project Doctype?
    2.Are you sending header with token with this request?

Hope this helps

Every request made is treated as unauthenticated as the user agent is not using session/cookies/sid.

Try your Administrator api_key:api_secret request with curl -v and you’ll get response headers like Insomnia.

Thank you, to both of you.
The issue was not sending the authentication header with the request and needing to specify the name of the doctype (Project, Lead, etc. versus “:doctype”)

curl -k --request GET \
  --url https://site1.localhost/api/resource/Lead \
  --header 'Authorization: token 59531e311365034:2b3836d48725b83'
{"data":[{"name":"CRM-LEAD-2023-00001"}]}