Request Failed: unacceptable content-type: text/html - AFNetworking 2 in Swift -



Request Failed: unacceptable content-type: text/html - AFNetworking 2 in Swift -

all,

i trying json url using afnetworking in swift. getting error : request failed unacceptable content-type : text/html

here code :

func makeget() { allow manager = afhttprequestoperationmanager() manager.requestserializer. manager.get(apiurl, parameters: nil, success: { (operation: afhttprequestoperation!, responseobject: anyobject!) in self.jsonloaded(responseobject.description) }, failure: { (operation: afhttprequestoperation!, error: nserror!) in self.jsonfailed(error) } )

i intend utilize :

manager.requestserializer.setvalue(<#value: string!#>, forhttpheaderfield: <#string!#>)

to set content-type text/html.

any ideas how ?

i have added :

manager.requestserializer.setvalue("text/html", forhttpheaderfield: "content-type")

this has not helped.

try this:

manager.responseserializer.acceptablecontenttypes = nsset(array: ["text/plain", "text/html", "application/json"]) set<nsobject>

or faster:

manager.responseserializer = [afhttpresponseserializer serializer];

swift afnetworking-2

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -