I'm using the Requests library to send data to a server, using the following code:

r=requests.post(
        url='http://localhost:8000/api/open/',
        data=json.dumps({"name":"awdawd"}),
        headers={'content-type':'aplication/json'},
    )

However, I'm getting the following error:

"error_message": "The format indicated 'aplication/json' had no available deserialization method. Please check your ``formats`` and ``content_types`` on your Serializer."

Does anyone have a clue on this?

Thanks very much

有帮助吗?

解决方案

Its just a misspelling in application

r=requests.post(url='http://localhost:8000/api/open/',                
                data=json.dumps({"name":"awdawd"}),
                headers={'content-type':'application/json'})
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top