Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

427
Vistas
sending ajax get request with content type :application/xml is still giving me json response

I've been constructing this ajax request

<script>
  $.ajax({
      url:"https://api.asd.com/v1/book?limit_bids=450&limit=20",
        type:"GET",

      data:{


  },
      contentType:"application/xml",
      success: function (response) {
           console.log(headers),
          console.log(response)

      }

  });
  </script>

i was expecting it to return a xml based response or text/html based 400 bad request [which it should]

but instead i got JSON response

but triggering the same request in burp or postman is giving me the response which i wanted

enter image description here

the thing is content-lenfth is required to get that exact response

but having content-length header is not being accepted in ajax request so im assuming content-length will autoamtically be added by ajax while sending the data in requet

      data:{
"asd"

  },

is giving me error

      data:{
"asd":"asd"

  }

is still giving me a json response

so how exactly i need to construct the request?

so that i can get the response i wanted from that image not just ajax but any other methods like

jquery or XMLHttpRequest
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Ajax GET requests do not have body content so they would not have content lengths or content types.
If you want to tell the api that you want an xml response you have to set the dataType field in $.ajax. This of course has to be supported by the API, just saying you want xml doesn't guarantee you will get it.

$.ajax({
  url:"https://api.asd.com/v1/book?limit_bids=450&limit=20",
  type:"GET",
  dataType:"xml",
  success: function (response) {
    console.log(response);
  }
});
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda