tomdionysus / foaas

FOAAS (Fuck Off As A Service) provides a modern, RESTful, scalable solution to the common problem of telling people to fuck off.
http://foaas.com
Do What The F*ck You Want To Public License
2.99k stars 394 forks source link

API Response #252

Closed FeelsBadMan1 closed 3 years ago

FeelsBadMan1 commented 3 years ago

Hello, somehow the api not returns json objects but text instead. here is what i did:

request url: https://foaas.com/absolutely/discorduser/a really cool person response error: raise ContentTypeError( aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://foaas.com/absolutely/discorduser/a%20really%20cool%20person')

bakhoraliev commented 3 years ago

You miss one field in headers: accept: application/json

import requests

requests.get("https://foaas.com/absolutely/discorduser/a%20really%20cool%20person").json() # raise similar exception
requests.get("https://foaas.com/absolutely/discorduser/a%20really%20cool%20person", headers={"accept": "application/json"}).json() # return valid json
FeelsBadMan1 commented 3 years ago

thank u, That solved the issure i had ;D as of solved now im closing this issue