0

I use Angular 9 for sending some headers such as page size and current page to my asp.net mvc core back end over IIS server . when my request is to http address every thing is OK ,but when I use https for calling API, header values not sent correctly and pagging not work . I test my https back end with postman and it work through it.

 let headers = new HttpHeaders({ 'Content-Type': 'application/json' });
       headers = headers.set('PageSize', pageSize.toString());
       headers = headers.set('CurrentPage', currentPage.toString());

How can I send my header request correctly?

2
  • What error can you see? Does the Api call succeed but with incorrect data? If the call fails in https only (but works with postman) it might be because of a CORS issue Commented May 13, 2020 at 7:02
  • I don't have CORS problem . just my headers not send by https (ssl). my Authorization JWT Token is sending via header but my pagesize not sending. also every thing works with http Commented May 16, 2020 at 6:44

1 Answer 1

1

Try this way: Make sure you include the headers in your api call

var pageS = pageSize.toString()
var currentP = currentPage.toString()
var headers = new HttpHeaders({
    'Content-Type': 'application/json',
    'PageSize': pageS,
    'CurrentPage': currentP
});

return this._http.post('https://localhost:5001/api/', {
        object
    }, {
        headers
    })
    .subscribe(res => console.log(res));
Sign up to request clarification or add additional context in comments.

2 Comments

I send request and receive response over http correctly . other steps are true and i sned header in my request. my problem is just with https.
Ah ok. Take a look at this file: medium.com/@rubenvermeulen/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.