curl -H "Authorization: Token token=sfg999666t673t7t82" -H "Content-Type: application/json" -d '{"phone_call": { "call_direction": true, "targetable_type": "contact", "targetable": { "id": "1", "first_name": "Jane", "last_name": "Sampleton (sample)", "work_number ":"5304915427", "mobile_number ":"11919457004 " }, "note ": { "description": "Sample note"} }}' -X POST https://domain.myfreshworks.com/crm/sales/api/phone_callsCuando hago esta solicitud, obtengo la respuesta con éxito, pero solo quiero hacer la misma solicitud con axios. Cómo puedo hacer eso ? Intento esto pero no funciona. Obtengo un error cors.
const headers = { 'Content-Type': 'application/json', Authorization: 'Token sfg999666t673t7t82', }; var dataString = '{"phone_call": { "call_direction": true, "targetable_type": "contact", "targetable": { "id": "1", "first_name": "Jane", "last_name": "Sampleton (sample)", "work_number ":"5304915427", "mobile_number ":"11919457004 " }, "note ": { "description": "Sample note"} }}'; Axios.post('https://domain.myfreshworks.com/crm/sales/api/phone_calls', dataString, { headers: headers, }) .then((response) => { console.log(response); }) .catch((error) => { console.log(error); }); ``Los encabezados parecen incorrectos en su versión de axios .
Authorization: Token token=sfg999666t673t7t82 no es lo mismo que Authorization: 'Token sfg999666t673t7t82' .
Intente cambiar Authorization: 'Token sfg999666t673t7t82' a Authorization: 'Token token=sfg999666t673t7t82' para que las solicitudes sean equivalentes.