# How to Add API-key and API-username in Angular services

**URL:** https://meta.discourse.org/t/how-to-add-api-key-and-api-username-in-angular-services/185859
**Category:** Support
**Created:** [April 7, 2021, 10:41am UTC](https://meta.discourse.org/t/how-to-add-api-key-and-api-username-in-angular-services/185859 "2021-04-07T10:41:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sanjeevconverge](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@sanjeevconverge](https://meta.discourse.org/u/sanjeevconverge)
#### Post date: [April 7, 2021, 10:41am UTC](https://meta.discourse.org/t/how-to-add-api-key-and-api-username-in-angular-services/185859/1 "2021-04-07T10:41:32Z")

</div>

can anyone please guide me How to Add API-key and API-username in Angular services  
for example  
return this.http.get(‘[https://converge.trydiscourse.com/categories.json](https://converge.trydiscourse.com/categories.json)’, { ‘Api-Key’: ‘123456789’, ‘Api-Username’: ‘system’});  
here i am getting error.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [April 8, 2021, 5:20pm UTC](https://meta.discourse.org/t/how-to-add-api-key-and-api-username-in-angular-services/185859/2 "2021-04-08T17:20:25Z")

</div>

I suspect that the issue is happening because your code it adding the `Api-Key` and `Api-Username` as query parameters to the `GET` request. The `Api-Key` and `Api-Username` needed to be included in the request’s headers, not as query parameters. There is a curl example of how to set this up in the Authentication section that is near the top of this page: [https://docs.discourse.org/](https://docs.discourse.org/).

---

<div class="post-metadata">

### Author: ![sanjeevconverge](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@sanjeevconverge](https://meta.discourse.org/u/sanjeevconverge)
#### Post date: [April 9, 2021, 8:15am UTC](https://meta.discourse.org/t/how-to-add-api-key-and-api-username-in-angular-services/185859/3 "2021-04-09T08:15:12Z")

</div>

Issue resolved by my self  
fetchCategory() {  
const headers = new HttpHeaders()  
.set(‘Api-Key’, ‘123456’)  
.set(‘Api-Username’, ‘abcd’);  
const result = this.http.get(‘[https://url.json](https://url.json)’,{headers }); return result;  
}  
And also i enabled the cors from by browser and now its working fine
