# Okta Angular, error 500

**URL:** <https://devforum.okta.com/t/okta-angular-error-500/13402>\
**Category:** Questions\
**Created:** [March 17, 2021, 11:03pm UTC](https://devforum.okta.com/t/okta-angular-error-500/13402 "2021-03-17T23:03:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramonab](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@ramonab](https://devforum.okta.com/u/ramonab)\
**Post date:** [March 17, 2021, 11:03pm UTC](https://devforum.okta.com/t/okta-angular-error-500/13402/1 "2021-03-17T23:03:30Z")

</div>

hi, I have a hard time passing the right angular request to the header. This is my service:

```
import { Injectable } from '@angular/core';
import { HttpClient, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpHeaders } 
from '@angular/common/http';
import { Utente } from '../model/Utente ';
import { Prodotto } from '../model/Prodotto ';
import { OktaAuthService } from '@okta/okta-angular';
import { Observable, from } from 'rxjs';
import { Carrello } from '../model/Carrello ';
import { userInfo } from 'node:os';
import { getLocaleCurrencyCode } from '@angular/common';

const headers = new HttpHeaders().set('Accept', 'application/json');

@Injectable({
 providedIn: 'root'
})
export class HttpClientService {

 constructor(
private httpClient:HttpClient, private oktaAuth:OktaAuthService ) {}

  getCarr(){
return this.httpClient.get<Carrello[]>('http://localhost:8080/prodotti/utente/vedicarrelloo', {headers} );
}

```

}`

This is my spring method:

```
@Transactional(readOnly = true)
public List<Carrello> getCarrello(@AuthenticationPrincipal OidcUser utente){
    Utente u= utenteRepository.findByEmail(utente.getEmail());
    return carrelloRepository.findByUtente(u);
}

```

In console I get this error:

![errore](https://global.discourse-cdn.com/oktadev/original/2X/b/bc229207eecbd9d9339e1d6f4de776418faf8889.png)

this error corresponds in my console to "java.lang.NullPointerException: null.

But if I access localhost: 8080, I can see the answer correctly, so I assume there is a problem in passing the request header in angular, can anyone tell me where am I wrong, please? I specify that I get this error only in the methods where the OidcUser is present, the rest works perfectly. Thank you!

---

<div class="post-metadata">

**Author:** ![gpadma](https://avatars.discourse-cdn.com/v4/letter/g/858c86/32.png) [@gpadma](https://devforum.okta.com/u/gpadma)\
**Post date:** [March 18, 2021, 6:17pm UTC](https://devforum.okta.com/t/okta-angular-error-500/13402/2 "2021-03-18T18:17:34Z")

</div>

@ramonab,

It looks like OidcUser object is null ? Not sure if this is related to the headers as you’ve mentioned.

---

<div class="post-metadata">

**Author:** ![ramonab](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@ramonab](https://devforum.okta.com/u/ramonab)\
**Post date:** [March 22, 2021, 12:26pm UTC](https://devforum.okta.com/t/okta-angular-error-500/13402/3 "2021-03-22T12:26:18Z")

</div>

What could it be? if I access from the client, then from localhost: 8080, I see the requested info and then the oidcUser object

---

<div class="post-metadata">

**Author:** ![sigama](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/sigama/32/5811_2.png) [@sigama](https://devforum.okta.com/u/sigama)\
**Post date:** [March 22, 2021, 6:30pm UTC](https://devforum.okta.com/t/okta-angular-error-500/13402/4 "2021-03-22T18:30:23Z")

</div>

Hi @ramonab! Please open a support ticket through an email to [support@okta.com](mailto:support@okta.com) with this issue. One of our Support Engineers will be able to take a closer look at your headers/setup.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 27, 2024, 12:04am UTC](https://devforum.okta.com/t/okta-angular-error-500/13402/5 "2024-01-27T00:04:34Z")

</div>

Closed on January 27, 2024, 12:04am UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
