Call to RESP APIs using .NET HttpWebRequest - keep getting 403

Hi there,

I am trying to call the REST APIs using only .NET (HttpWebRequest). I can successfully log in, but any subsequent call returns a 403. The calls I am making are:

POST to /api/method/login - Succeeds
GET /api/method/frappe.auth.get_logged_user - Fails with 403

(I do pass the CookieContainer from the 1st to the 2nd call, in case you are wondering)

I have followed all the suggestions I could find, but I am obviously still missing something. Does anyone have a sample of code that I could look at?

Pure .NET please, no external libraries.


Hi here,

Never mind about this, I have just figured it out.

For those interested, the session cookie (“sid”) was coming back with an expires in the past. Changing the expires fixed it.

1 Like