Search code examples
pythonrestcurlbottle

Bottle POST or PUT requests don't see more than one parameter


I'm trying to pass several parameters using POST or PUT, but I'm getting only first

@route('/command/', method='PUT')
def execute(command="Unknown"):
    param1 = request.query.get("param1")
    param2 = request.query.get("param2")
    param3 = request.query.get("param3")
    print("{} {} {} {}".format(command, param1, param2, param3))
    return "Executed {} {} {} {}".format(command, param1, param2, param3)

using the request like this:

curl -X PUT http://host:port/mycommand/?param1=value1&param2=value2&param3=value3

Bottle logs: "PUT /command/?param1=value1 HTTP/1.1" and param2 and param3 are printed out as "None", like they are cut off on the &


Solution

  • You need to put quotes around the URL:

    curl -X PUT "http://host:port/mycommand/?param1=value1&param2=value2&param3=value3"