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
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
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!)
}
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.