Reputation: 7168
i wrote a .json file and want to download it with AFNetworking. But AFNetworking complains: fail Expected content type {( "text/json", "application/json", "text/javascript" )}, got text/plain
my JSON file test.json
{
"count-packages": 5,
"packages":
{
"de":
{
"0": "Wackel Dackel",
"1": "Hans Wurst",
"2": "Peter Ploes",
"3": "Tiffel Toffel",
"4": "China Mann"
},
"en":
{
"0": "Wobble dachshund",
"1": "Hans Sausage",
"2": "Peter Ploes",
"3": "Tiffel Potato",
"4": "Peking Ente"
}
}
}
HTTP/1.1 200 OK
Date: Mon, 06 Feb 2012 17:31:06 GMT
Server: Apache/1.3.41 Ben-SSL/1.59
Last-Modified: Mon, 06 Feb 2012 17:28:13 GMT
ETag: "18039c71-205-4f300dad"
Accept-Ranges: bytes
Content-Length: 517
Content-Type: text/plain
How can I change the Content-Type?
Upvotes: 2
Views: 7044
Reputation: 4463
It is the issue on the server side. If you have control to the Apache server, add following line in httpd.conf
application/json json
EDIT : I was wrong of the syntax with my answer above. The lines like above should go into mime.types
file as @James suggests. But you can use AddType
directive and specify mime types in httpd.conf
as well.
AddType application/json .json
Upvotes: 3
Reputation: 3475
If you don't have access to httpd.conf
(like in many cases) you can create a .htaccess
file and simply write AddType application/json .json
inside. Put it next your json file and it should be OK !
Upvotes: 1
Reputation: 13010
You'll need to add an appropriate entry for .json to the Apache mime.types file. See Setting up MIME Types with Apache
Upvotes: 1
Reputation: 1780
You can't change the content type for a .json file. Probably the error comes from the javascript, ther you sould change or parse as Json
Upvotes: -1