Reputation: 33
I am getting 406 not acceptable when i try to access http://localhost:5000/soap/someservice
API Error: The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request. Supported entities are text/html.
Here is a snippet from the server side
from flask import Flask, jsonify
from flask_accept import accept
app = Flask(__name__)
@app.route('/soap/someservice')
@accept('text/html')
def hello_world():
return 'Hello World!'
What i tried on the client side:
from suds.client import Client
url = 'http://localhost:5000/soap/someservice?wsdl'
client = Client(url)
406 not acceptable
import requests
r=requests.get("http://localhost:5000/soap/someservice", headers={"content-type":"text"})
print(r)
406 not acceptable
All solutions give the same error any hints ?
Upvotes: 3
Views: 1361
Reputation: 34618
You have specified
@accept('text/html')
In the Flask endpoint, but you have not provided an Accept Header specifying text/html
in your request. Compare running your Flask app, but using:
In [3]: import requests
...: r=requests.get("http://localhost:5000/soap/someservice",
headers={"Accept":"text/html"})
...: print(r)
...:
<Response [200]>
Upvotes: 2