Unexpected empty value on HTTP request body in Angular

I am stucking in the creation of an Angular project.

During the call to the LOGI webservice, which allows the user to connect. In the DEPO input: I added the account number 979963840303 hardcoded.

 signIn(model: SignInModel): Observable < ApiResponse > {
    const header: ApiHeader = this.store.selectSnapshot(AuthState.header);
    header.USER = model.uid;

    return this.generateToken().pipe(
        switchMap(token => {
            model.token = token;
            return this.http.post < AuthResponse > (this.api + `/LOGI`, {
                HEADER: {
                    ...header,
                    USER: model.uid,
                    VERSION: model.version,
                    LANGUAGE: model.language,
                },
                SSO_IN: {
                    VIA_SSO: "TRUE",
                    DEPO: 979963840303,
                    MODE: "Trans",
                    TOKEN: token
                },
            });
        }),
        switchMap(response => {
            if (response.RETURNCODE === ApiResponseCodeEnum.Ok) {
                if (!response.SSO_OUT) {
                    this.logout().subscribe();
                }

                this.store.dispatch(new SetAuthStateAction({
                    user: model.uid,
                    session: response.IDSESSION,
                    language: model.language,
                    numTrx: response.INFO_HEADER.NUMTRX,
                    channel: response.INFO_HEADER.CHANNEL,
                    lastConnexionTime: response.INFO_HEADER.LAHECO,
                    lastConnexionDate: response.INFO_HEADER.LADACO,
                    lastErrorTime: response.INFO_HEADER.LAHEPWD,
                    lastErrorDate: response.INFO_HEADER.LADAPWD,
                    tiers: response.INFO_HEADER.TIERS,
                    version: model.version,
                    userType: response.INFO_HEADER.IDENTIF
                }));

                this.store.dispatch(new SetPortfoliosAction(response.SSO_OUT));
                this.store.dispatch(new SetCurrentPortfolioAction({
                    CLER: response.SSO_OUT.CLER,
                    DEPO: response.SSO_OUT.DEPO,
                    INT_PTF: response.SSO_OUT.INT_PTF,
                    COD_TIT: response.SSO_OUT.COD_TIT,
                    AGENCE_NUM: response.SSO_OUT.AGENCE_NUM,
                    AGENCE_LIB: response.SSO_OUT.AGENCE_LIB,
                    IAT: response.SSO_OUT.IAT,
                    GRANTS: response.SSO_OUT.GRANTS
                }));

                return this.getSolde().pipe(
                    switchMap(soldeResponse => {
                        if (soldeResponse.RETURNCODE === ApiResponseCodeEnum.Ok) {
                            this.store.dispatch(new SetAuthStateAction({
                                user: model.uid,
                                session: response.IDSESSION,
                                language: model.language,
                                numTrx: response.INFO_HEADER.NUMTRX,
                                channel: response.INFO_HEADER.CHANNEL,
                                lastConnexionTime: response.INFO_HEADER.LAHECO,
                                lastConnexionDate: response.INFO_HEADER.LADACO,
                                lastErrorTime: response.INFO_HEADER.LAHEPWD,
                                lastErrorDate: response.INFO_HEADER.LADAPWD,
                                tiers: response.INFO_HEADER.TIERS,
                                version: model.version,
                                userType: response.INFO_HEADER.IDENTIF,
                                solde: soldeResponse.PTF.SOLDE,
                            }));
                        }
                        return of(soldeResponse);
                    })
                );
            }
            return of(response);
        })
    );
 }

The user connects and the client’s account information is displayed, here is what I retrieve in the console log.

The variable REFERENCE retrieves the account number 979963840303.

Now my problem is that I should not display this account number as a hard-coded value! Because, each user has a different account number!

I have modified

DEPO: 979963840303, 

By

 DEPO: model.depo, 

I reconnect and I see this in payload, is the DEPO variable empty?

In the console log, the REFERENCE variable is equal to 0.

Why is the account number empty when I use a variable? However, everything works if I add the value directly -> 979963840303 ?

Here are my two components

identity.service.ts

@Injectable()
export class IdentityService {
  private readonly api: string = environment.api;

  constructor(
    private http: HttpClient,
    private store: Store,
    private router: Router
  ) {}

  generateToken(): Observable<string> {
    const header: ApiHeader = this.store.selectSnapshot(AuthState.header);
    return this.http
      .post<{ TOKEN: string }>(this.api + `/MKTK`, {
        HEADER: header,
        MODE: "Trans",
      })
      .pipe(
        map((response) => {
          return response.TOKEN;
        })
      );
  }

  signIn(model: SignInModel): Observable<ApiResponse> {
    const header: ApiHeader = this.store.selectSnapshot(AuthState.header);
    header.USER = model.uid;

    return this.generateToken().pipe(
      switchMap((token) => {
        model.token = token;
        return this.http.post<AuthResponse>(this.api + `/LOGI`, {
          HEADER: {
            ...header,
            USER: model.uid,
            VERSION: model.version,
            LANGUAGE: model.language,
          },
          SSO_IN: {
            VIA_SSO: "TRUE",
            DEPO: model.depo,
            MODE: "Trans",
            TOKEN: token,
          },
        });
      }),
      switchMap((response) => {
        if (response.RETURNCODE === ApiResponseCodeEnum.Ok) {
          if (!response.SSO_OUT) {
            this.logout().subscribe();
          }

          this.store.dispatch(
            new SetAuthStateAction({
              user: model.uid,
              session: response.IDSESSION,
              language: model.language,
              numTrx: response.INFO_HEADER.NUMTRX,
              channel: response.INFO_HEADER.CHANNEL,
              lastConnexionTime: response.INFO_HEADER.LAHECO,
              lastConnexionDate: response.INFO_HEADER.LADACO,
              lastErrorTime: response.INFO_HEADER.LAHEPWD,
              lastErrorDate: response.INFO_HEADER.LADAPWD,
              tiers: response.INFO_HEADER.TIERS,
              version: model.version,
              userType: response.INFO_HEADER.IDENTIF,
            })
          );

          this.store.dispatch(new SetPortfoliosAction(response.SSO_OUT));
          this.store.dispatch(
            new SetCurrentPortfolioAction({
              CLER: response.SSO_OUT.CLER,
              DEPO: response.SSO_OUT.DEPO,
              INT_PTF: response.SSO_OUT.INT_PTF,
              COD_TIT: response.SSO_OUT.COD_TIT,
              AGENCE_NUM: response.SSO_OUT.AGENCE_NUM,
              AGENCE_LIB: response.SSO_OUT.AGENCE_LIB,
              IAT: response.SSO_OUT.IAT,
              GRANTS: response.SSO_OUT.GRANTS,
            })
          );

          return this.getSolde().pipe(
            switchMap((soldeResponse) => {
              if (soldeResponse.RETURNCODE === ApiResponseCodeEnum.Ok) {
                this.store.dispatch(
                  new SetAuthStateAction({
                    user: model.uid,
                    session: response.IDSESSION,
                    language: model.language,
                    numTrx: response.INFO_HEADER.NUMTRX,
                    channel: response.INFO_HEADER.CHANNEL,
                    lastConnexionTime: response.INFO_HEADER.LAHECO,
                    lastConnexionDate: response.INFO_HEADER.LADACO,
                    lastErrorTime: response.INFO_HEADER.LAHEPWD,
                    lastErrorDate: response.INFO_HEADER.LADAPWD,
                    tiers: response.INFO_HEADER.TIERS,
                    version: model.version,
                    userType: response.INFO_HEADER.IDENTIF,
                    solde: soldeResponse.PTF.SOLDE,
                  })
                );
              }
              return of(soldeResponse);
            })
          );
        }
        return of(response);
      })
    );
  }

  logout(redirect: boolean = true): Observable<any> {
    return this.store.dispatch(new ResetAuthStateAction()).pipe(
      concatMap(() => this.store.dispatch(new ResetProfileStateAction())),
      tap(() => {
        if (redirect) {
          this.router.navigate(["/sessions/signin"]);
        }
      })
    );
  }

  signOut(): Observable<ApiResponse> {
    return this.http
      .post<AuthResponse>(this.api + `/LOGO`, {})
      .pipe(concatMap(() => this.logout()));
  }

  getSolde(): Observable<SoldeResponse> {
    return this.http.post<SoldeResponse>(
      this.api + `/GPTF`,
      {},
      { headers: { AddCustomer: "" } }
    );
  }
}

identity.sandbox.ts

@Injectable()
export class IdentitySandbox {
  @Select(AuthState.isAuthenticated) isAuthenticated$!: Observable<boolean>;

  constructor(private service: IdentityService) {}

  signIn(model: SignInModel): Observable<ApiResponse> {
    return this.service.signIn(model);
  }

  logout(): void {
    this.service.logout();
  }

  signOut(): Observable<ApiResponse> {
    return this.service.signOut();
  }
}

identity.component.ts

export class IdentityComponent implements OnInit {
  readonly supportedLangs: string[] = environment.supportedLanguages;

  constructor(private sandbox: IdentitySandbox, private router: Router) {}

  ngOnInit(): void {
    this.sandbox.isAuthenticated$.pipe(take(1)).subscribe((res) => {
      if (res) {
        this.router.navigate(["/"]);
      }
    });
  }
}

identity.component.html

<router-outlet></router-outlet> 

signin.service.ts

@Injectable()
export class SigninService {
  private readonly api: string = environment.api;

  constructor(
    private http: HttpClient,
    private store: Store,
    private identitySandbox: IdentitySandbox
  ) {}

  signIn(model: SignInModel): Observable<ApiResponse> {
    return this.identitySandbox.signIn(model);
  }
}

signin.component.ts

export class SigninComponent implements OnInit {
  private unsubscribe$ = new Subject<void>();

  tokens: SignatureOtpModel = new SignatureOtpModel();
  ngUnsubscribe = new Subject<void>();

  private model: SignInModel = new SignInModel();

  readonly supportedLangs: string[] = environment.supportedLanguages;

  constructor(
    private router: Router,
    private service: SigninService,
    private sandbox: AppSandbox
  ) {}

  ngOnInit(): void {}

  signIn(): void {
    this.model.uid = this.tokens.user;
    this.model.language = "FR";
    this.model.mode = "Trans";
    //  this.model.depo = 979963840303;

    this.service
      .signIn(this.model)
      .pipe(takeUntil(this.unsubscribe$))
      .subscribe((res) => {
        console.log("SignIn response:", res);
        if (res.RETURNCODE === ApiResponseCodeEnum.Ok) {
          this.router.navigate(["/online/portfolio/stocks"]);
        } else {
          console.error("SignIn failed, redirecting to logon");
          this.logon();
        }
      });
  }

  logon(): void {
    console.log("Before navigating, model values are:", {
      MODE: this.model.mode,
      TOKEN: this.model.token,
      DEPO: this.model.depo,
    });

    this.router.navigate(["/sessions/logon"], {
      queryParams: {
        DEPO: this.model.depo,
        MODE: this.model.mode,
        TOKEN: this.model.token,
      },
    });
  }

  selectLanguage(language: string): void {
    this.sandbox.setLanguage(language);
  }
}

signIn.model.ts

export class SignInModel {
  uid: string;
  version: string;
  modeCtrl: string;
  todo: string;
  menu: number;
  date: string;
  url: string;
  language: string;
  mode: string;
  token: any;
  depo: any;

  constructor() {
    this.uid = "";
    this.version = "";
    this.modeCtrl = "";
    this.todo = "";
    this.menu = 0;
    this.date = "";
    this.url = "";
    this.language = "";
    this.mode = "";
    this.token = "";
    this.depo = "";
  }
}

I thank you for your help and the time you dedicated to my problem.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật