Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

425
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!