0

I am sending data in JSON with content-type JSON but this shows me the content-type XML. So the server could not read my request.

Also, that is the post request

See this

Salman Ghumsani
  • 3,647
  • 2
  • 21
  • 34

2 Answers2

0

The problem is that you are using .responseJSON which tells Alamofire that the response would contain JSON. Since the response is XML and not JSON in your case, Alamofire would throw an error. What you need instead is not to specify the response type and then an XMLParser to parse the data. One option is SWXMLHash. Your updated code would look something like this

Alamofire.request(request)
         .response { response in
            var xml = SWXMLHash.parse(response.data!)
         }
Malik
  • 3,763
  • 1
  • 22
  • 35
  • I am checking this but the api says me the response will be in json `https://apicurrent-app.booker.ninja/WebService4/json/CustomerService.svc/customer` – Salman Ghumsani Jul 21 '17 at 09:10
  • This link returns a `404`. Also, in your logs, it returns `500`. Might be something worth looking into to make sure you are getting a response from the server and that it is, in fact, in the right format – Malik Jul 21 '17 at 09:12
0

Basically, this is not an error of content-type. this is an error of data type.

I send the all value in the string but there is need to send the data with data type.

When I request with data type it automatically changed content-type in JSON.

Salman Ghumsani
  • 3,647
  • 2
  • 21
  • 34