Adding a cookie to a HttpClient POST in Angular Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Angular 5, httpclient ignores set cookie in postJavaScript post request like a form submitPUT vs. POST in RESTHow do I set/unset a cookie with jQuery?Local Storage vs CookiesHow to make HTTP POST web requestHow to retrieve POST query parameters?How is an HTTP POST request made in node.js?How are parameters sent in an HTTP POST request?Automatically Update Cookies From HTTP Post Request With Multiple Redirects In SwiftGet updated XSRF token and Cookie after login: Angular 4
Does the Black Tentacles spell do damage twice at the start of turn to an already restrained creature?
Weaponising the Grasp-at-a-Distance spell
Is there hard evidence that the grant peer review system performs significantly better than random?
Mounting TV on a weird wall that has some material between the drywall and stud
How can I prevent/balance waiting and turtling as a response to cooldown mechanics
Is multiple magic items in one inherently imbalanced?
Is openssl rand command cryptographically secure?
Trying to understand entropy as a novice in thermodynamics
Tips to organize LaTeX presentations for a semester
Co-worker has annoying ringtone
what is the log of the PDF for a Normal Distribution?
Can an iPhone 7 be made to function as a NFC Tag?
Putting class ranking in CV, but against dept guidelines
Simple Http Server
Why is a lens darker than other ones when applying the same settings?
A proverb that is used to imply that you have unexpectedly faced a big problem
Google .dev domain strangely redirects to https
How to align enumerate environment inside description environment
I got rid of Mac OSX and replaced it with linux but now I can't change it back to OSX or windows
White walkers, cemeteries and wights
Does the Mueller report show a conspiracy between Russia and the Trump Campaign?
What does Turing mean by this statement?
How many time has Arya actually used Needle?
Delete free apps from library
Adding a cookie to a HttpClient POST in Angular
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Angular 5, httpclient ignores set cookie in postJavaScript post request like a form submitPUT vs. POST in RESTHow do I set/unset a cookie with jQuery?Local Storage vs CookiesHow to make HTTP POST web requestHow to retrieve POST query parameters?How is an HTTP POST request made in node.js?How are parameters sent in an HTTP POST request?Automatically Update Cookies From HTTP Post Request With Multiple Redirects In SwiftGet updated XSRF token and Cookie after login: Angular 4
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Sorry if this is a duplicate, but I have not been able to find any solutions that have worked for me yet. My code works like this:
constructor(private _httpClient: HttpClient)
login()
var cookieToAdd = getCookie();
var token = getToken();
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token , cookieToAdd )
.subscribe((result: any) =>
// do stuff here
);
So obviously the last parameter in the post is incorrect, but I hope you see the point. I wish to make this post request with a cookie I have obtained from a previous api call, but I cannot find how to add a cookie to a post request using Angulars HttpClient. The endpoint returns an error if the cookie is not present. I have received my desired output from the endpoint using Postman, but cannot replicate adding the cookie properly in code. Any help would be greatly appreciated.
edit:
I have also tried something like:
var myHeaders = new HttpHeaders('Set-Cookie': 'CookieName='+cookieToAdd');
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token , headers: myHeaders )
.subscribe((result: any) =>
// do stuff here
);
angular typescript post cookies
add a comment |
Sorry if this is a duplicate, but I have not been able to find any solutions that have worked for me yet. My code works like this:
constructor(private _httpClient: HttpClient)
login()
var cookieToAdd = getCookie();
var token = getToken();
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token , cookieToAdd )
.subscribe((result: any) =>
// do stuff here
);
So obviously the last parameter in the post is incorrect, but I hope you see the point. I wish to make this post request with a cookie I have obtained from a previous api call, but I cannot find how to add a cookie to a post request using Angulars HttpClient. The endpoint returns an error if the cookie is not present. I have received my desired output from the endpoint using Postman, but cannot replicate adding the cookie properly in code. Any help would be greatly appreciated.
edit:
I have also tried something like:
var myHeaders = new HttpHeaders('Set-Cookie': 'CookieName='+cookieToAdd');
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token , headers: myHeaders )
.subscribe((result: any) =>
// do stuff here
);
angular typescript post cookies
add a comment |
Sorry if this is a duplicate, but I have not been able to find any solutions that have worked for me yet. My code works like this:
constructor(private _httpClient: HttpClient)
login()
var cookieToAdd = getCookie();
var token = getToken();
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token , cookieToAdd )
.subscribe((result: any) =>
// do stuff here
);
So obviously the last parameter in the post is incorrect, but I hope you see the point. I wish to make this post request with a cookie I have obtained from a previous api call, but I cannot find how to add a cookie to a post request using Angulars HttpClient. The endpoint returns an error if the cookie is not present. I have received my desired output from the endpoint using Postman, but cannot replicate adding the cookie properly in code. Any help would be greatly appreciated.
edit:
I have also tried something like:
var myHeaders = new HttpHeaders('Set-Cookie': 'CookieName='+cookieToAdd');
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token , headers: myHeaders )
.subscribe((result: any) =>
// do stuff here
);
angular typescript post cookies
Sorry if this is a duplicate, but I have not been able to find any solutions that have worked for me yet. My code works like this:
constructor(private _httpClient: HttpClient)
login()
var cookieToAdd = getCookie();
var token = getToken();
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token , cookieToAdd )
.subscribe((result: any) =>
// do stuff here
);
So obviously the last parameter in the post is incorrect, but I hope you see the point. I wish to make this post request with a cookie I have obtained from a previous api call, but I cannot find how to add a cookie to a post request using Angulars HttpClient. The endpoint returns an error if the cookie is not present. I have received my desired output from the endpoint using Postman, but cannot replicate adding the cookie properly in code. Any help would be greatly appreciated.
edit:
I have also tried something like:
var myHeaders = new HttpHeaders('Set-Cookie': 'CookieName='+cookieToAdd');
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token , headers: myHeaders )
.subscribe((result: any) =>
// do stuff here
);
angular typescript post cookies
angular typescript post cookies
edited Mar 8 at 23:59
Jamie Taylor Sangerman
asked Mar 8 at 23:21
Jamie Taylor SangermanJamie Taylor Sangerman
1849
1849
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can pass cookie as a property of input object and check logic in your login function API
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token, cookie: cookievalue
the issue is I cannot changed the api endpoint. It is required that the cookie is passed in the header
– Jamie Taylor Sangerman
Mar 9 at 0:07
did you try this way stackoverflow.com/questions/48410884/…
– Hien Nguyen
Mar 9 at 0:13
I did but with no luck
– Jamie Taylor Sangerman
Mar 9 at 0:23
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072347%2fadding-a-cookie-to-a-httpclient-post-in-angular%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can pass cookie as a property of input object and check logic in your login function API
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token, cookie: cookievalue
the issue is I cannot changed the api endpoint. It is required that the cookie is passed in the header
– Jamie Taylor Sangerman
Mar 9 at 0:07
did you try this way stackoverflow.com/questions/48410884/…
– Hien Nguyen
Mar 9 at 0:13
I did but with no luck
– Jamie Taylor Sangerman
Mar 9 at 0:23
add a comment |
You can pass cookie as a property of input object and check logic in your login function API
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token, cookie: cookievalue
the issue is I cannot changed the api endpoint. It is required that the cookie is passed in the header
– Jamie Taylor Sangerman
Mar 9 at 0:07
did you try this way stackoverflow.com/questions/48410884/…
– Hien Nguyen
Mar 9 at 0:13
I did but with no luck
– Jamie Taylor Sangerman
Mar 9 at 0:23
add a comment |
You can pass cookie as a property of input object and check logic in your login function API
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token, cookie: cookievalue
You can pass cookie as a property of input object and check logic in your login function API
this._httpClient
.post("https://myApi/login", username: "myUsername", pw: "myPw", token: token, cookie: cookievalue
answered Mar 9 at 0:03
Hien NguyenHien Nguyen
3,1631819
3,1631819
the issue is I cannot changed the api endpoint. It is required that the cookie is passed in the header
– Jamie Taylor Sangerman
Mar 9 at 0:07
did you try this way stackoverflow.com/questions/48410884/…
– Hien Nguyen
Mar 9 at 0:13
I did but with no luck
– Jamie Taylor Sangerman
Mar 9 at 0:23
add a comment |
the issue is I cannot changed the api endpoint. It is required that the cookie is passed in the header
– Jamie Taylor Sangerman
Mar 9 at 0:07
did you try this way stackoverflow.com/questions/48410884/…
– Hien Nguyen
Mar 9 at 0:13
I did but with no luck
– Jamie Taylor Sangerman
Mar 9 at 0:23
the issue is I cannot changed the api endpoint. It is required that the cookie is passed in the header
– Jamie Taylor Sangerman
Mar 9 at 0:07
the issue is I cannot changed the api endpoint. It is required that the cookie is passed in the header
– Jamie Taylor Sangerman
Mar 9 at 0:07
did you try this way stackoverflow.com/questions/48410884/…
– Hien Nguyen
Mar 9 at 0:13
did you try this way stackoverflow.com/questions/48410884/…
– Hien Nguyen
Mar 9 at 0:13
I did but with no luck
– Jamie Taylor Sangerman
Mar 9 at 0:23
I did but with no luck
– Jamie Taylor Sangerman
Mar 9 at 0:23
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072347%2fadding-a-cookie-to-a-httpclient-post-in-angular%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown