api/devices 400 (Bad Request)

DIOGO5 years ago
adicionar_http(){


            let data =  JSON.stringify({
                            name    : this.name,
                            uniqueId: this.imei_serial,
                            groupid : this.groupo,
                            phone   : this.phone,
                            category: this.modelo,
                            model   : this.contato,
                            contact : this.placa,
                            attributes: {},
                            disabled  : 'false',
                            photo     : '',
                            // chassi: 'chassi',
                            //renavam: 'renavam',
                            //placa: 'placa' 
                })
            let headers = {
                            headers: {
                                //Authorization: 'Bearer ' + token //the token is a variable which holds the token
                                //'Content-Type': 'application/x-www-form-urlencoded',
                                'Content-Type':	'application/json',
                                'Accept' : 'application/json',
                                'Authorization': 'Basic '+this.$store.getters.getToken,
                                'Connection' : 'Keep-Alive',
                                'Access-Control-Allow-Origin': '*'
                            },
                            proxy: {
                                host: this.url[0]+this.url[1],
                                port: this.url[2]
                            }
                }

                this.$http.post(
                        this.$store.getters.getHost+'/api/devices', 
                        headers, 
                        data
                )
                .then( response => {
                        console.log(response)
                })

        }
DIOGO5 years ago

map:1 Access to XMLHttpRequest at 'http://207.180.234.233:13000/api/devices' from origin 'http://localhost:8081' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.