Getting 400 bad request when trying to access an API using Angular, but it works perfectly...

Discussão em 'Angular' iniciado por TJ37, Fevereiro 13, 2025.

  1. TJ37

    TJ37 Guest

    I have already tested this API and have made a GET request on the API using PostMan and got the response. But when trying to implement it on my Angular 6 application I get a 401 unauthorized error. This is my angular code:

    this.http.get('https://api.channeladvisor.com/v1/orders',{headers:{'Authorization':'Bearer *token*','Content-Type':'application/x-www-form-urlencoded','cache-control':'no-cache'}})
    .subscribe((response)=>{
    this.channel=response;
    console.log(this.channel)
    })
    }


    I have the token and have not displayed it in the code for security reasons. I have a feeling it has something with the headers syntax but I'm not so sure.

    Continue reading...

Compartilhe esta Página