-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
Description
When trying to send a POST request with a simple string using primp.post, the following error occurs:
RuntimeError: builder error: top-level serializer supports only maps and structs
Caused by:
top-level serializer supports only maps and structsHow to Reproduce
Flask Test Server
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/', methods=['POST'])
def home():
raw_data = request.get_data(as_text=True)
if not raw_data:
return jsonify({"error": "no data received"}), 400
return jsonify({
"string": raw_data,
}), 200
if __name__ == '__main__':
app.run(host='0.0.0.0', port=3000, debug=True)Works with curl:
curl -X POST --data "isastr" http://localhost:3000Works with requests:
import requests
response = requests.post(
url="http://localhost:3000",
data="isastr"
)
print(response.json())Fails with primp:
import primp
response = primp.post(
url="http://localhost:3000",
data="isastr" # this causes the error
)
print(response.json())It would be great if the library could support sending plain strings as the body of a POST request (similar to how requests handles it), or perhaps provide a more descriptive error message to help clarify the limitation. Totally understand if this is out of scope
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels