Reputation: 3738
I'm using curl
on the endpoint
http://0.0.0.0:5001/event/email/?event_type=open&email_type=questions
The result that I am getting is
{
"email_type": null,
"event_type": "open"
}
Why am I getting null
for email_type
? I suspect it has something to do with how the &
is being dealt with by Flask?
Part of my code is as follows:
from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class EmailOpen(Resource):
def get(self):
email_type = request.args.get("email_type")
event_type = request.args.get("event_type")
ad_id = request.args.get("ad_id")
# print(event_type,email_type)
if not ad_id:
return {"event_type":event_type,"email_type":email_type}
return {"event_type":event_type,"email_type":email_type,"ad_id":ad_id}
api.add_resource(EmailOpen, '/event/email/')
I've looked up people with similar problems but they don't seem to match my scenario exactly
Upvotes: 0
Views: 45
Reputation: 3738
Bash must be interpreting things differently, adding the ""
works.
curl "http://0.0.0.0:5001/event/email/?event_type=open&email_type=questions"
Upvotes: 1