L lentunti Member Licensed User Longtime User Jul 9, 2015 #1 Hi all, Is it possible to use HTTPJob.GetRequest.SetHeader to replicate a cookie like this one in CookieManager:- CookieManager1.SetCookie("https://devtablet.nwhub.co.uk/api/jobs/fetchJobs", "NWTABLETGATEWAYSESSION=lg9f3d66b04k77dfusek9bmfl5") I have to apply to to a HttpJob.download2 as opposed to a WebView. Is this possible? I have tried HTTPJob.GetRequest.SetHeader("SET-COOKIE", "NWTABLETGATEWAYSESSION=lg9f3d66b04k77dfusek9bmfl5; path=https://devtablet.nwhub.co.uk/api/jobs/fetchJobs") but it doesn't seem to work Thanks for any help. regards Lee
Hi all, Is it possible to use HTTPJob.GetRequest.SetHeader to replicate a cookie like this one in CookieManager:- CookieManager1.SetCookie("https://devtablet.nwhub.co.uk/api/jobs/fetchJobs", "NWTABLETGATEWAYSESSION=lg9f3d66b04k77dfusek9bmfl5") I have to apply to to a HttpJob.download2 as opposed to a WebView. Is this possible? I have tried HTTPJob.GetRequest.SetHeader("SET-COOKIE", "NWTABLETGATEWAYSESSION=lg9f3d66b04k77dfusek9bmfl5; path=https://devtablet.nwhub.co.uk/api/jobs/fetchJobs") but it doesn't seem to work Thanks for any help. regards Lee
sonicmayne Member Licensed User Longtime User Jul 9, 2015 #2 Are you setting the header after you call Download? See Erel's example here: https://www.b4x.com/android/forum/threads/set-http-request-header-with-httputils2.39413/#content Upvote 0
Are you setting the header after you call Download? See Erel's example here: https://www.b4x.com/android/forum/threads/set-http-request-header-with-httputils2.39413/#content
Erel B4X founder Staff member Licensed User Longtime User Jul 10, 2015 #3 You need to set "Cookie" not "Set-Cookie". Set-Cookie header is used by the server (in the response) to ask the browser to set the cookies. Upvote 0
You need to set "Cookie" not "Set-Cookie". Set-Cookie header is used by the server (in the response) to ask the browser to set the cookies.
L lentunti Member Licensed User Longtime User Jul 10, 2015 #4 Erel said: You need to set "Cookie" not "Set-Cookie". Set-Cookie header is used by the server (in the response) to ask the browser to set the cookies. Click to expand... This is now my code :- getJobs.download2("https://devtablet.nwhub.co.uk/api/jobs/fetchJobs", Array As String ("action", JSONstring)) getJobs.GetRequest.SetHeader("Cookie", "NWTABLETGATEWAYSESSION=lg9f3d66b04k77dfusek9bmfl5; path=https://devtablet.nwhub.co.uk/api/jobs/fetchJobs") Which now gives me an internal server error. Your you say that thus suggests that the cookie has worked but there is a problem on the server (Possible dumb question). thanks for your help. Lee Upvote 0
Erel said: You need to set "Cookie" not "Set-Cookie". Set-Cookie header is used by the server (in the response) to ask the browser to set the cookies. Click to expand... This is now my code :- getJobs.download2("https://devtablet.nwhub.co.uk/api/jobs/fetchJobs", Array As String ("action", JSONstring)) getJobs.GetRequest.SetHeader("Cookie", "NWTABLETGATEWAYSESSION=lg9f3d66b04k77dfusek9bmfl5; path=https://devtablet.nwhub.co.uk/api/jobs/fetchJobs") Which now gives me an internal server error. Your you say that thus suggests that the cookie has worked but there is a problem on the server (Possible dumb question). thanks for your help. Lee
Erel B4X founder Staff member Licensed User Longtime User Jul 12, 2015 #5 Note that cookies are managed automatically by HttpUtils2 (actually HttpClient). If the server has previously returned this cookie then you do not need to manually add it to the request. Upvote 0
Note that cookies are managed automatically by HttpUtils2 (actually HttpClient). If the server has previously returned this cookie then you do not need to manually add it to the request.