openbmc / phosphor-rest-server

REST server that transposes dbus interfaces to REST
Apache License 2.0
4 stars 11 forks source link

Problem while passing string and integer together in REST #20

Closed rahulmah closed 8 years ago

rahulmah commented 8 years ago

For setting syslog, we have pass directory of string(for ip address) and integer (for port no.). If we try to give both of them (as below), I am getting "Expected a string or unicode object" error.

If we try to set ip address(as string) and port no.(as integer) separately, then we do not see any problem.

rahuls-MacBook-Pro:~ rahulmaheshwari$ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST -d "{\"data\": [{\"ipaddr\":\"9.109.116.67\", \"port\": 500}]}" ttps://9.3.164.147/org/openbmc/LogManager/rsyslog/action/Enable { "data": { "description": "Internal Server Error", "exception": "TypeError('Expected a string or unicode object',)", "traceback": [ "Traceback (most recent call last):", " File \"/usr/lib/python2.7/site-packages/bottle.py\", line 862, in _handle", " return route.call(*_args)", " File \"/usr/lib/python2.7/site-packages/bottle.py\", line 1734, in wrapper", " rv = callback(_a, ka)", " File \"/usr/sbin/obmc-rest\", line 616, in call", " return self.callback(_a, _kw)", " File \"/usr/sbin/obmc-rest\", line 707, in wrap", " resp = {'data': callback(_a, _kw)}", " File \"/usr/sbin/obmc-rest\", line 670, in wrap", " return callback(_a, _kw)", " File \"/usr/sbin/obmc-rest\", line 695, in wrap", " return callback(_a, _kw)", " File \"/usr/sbin/obmc-rest\", line 105, in call", " return getattr(self, 'do_' + request.method.lower())(_kw)", " File \"/usr/sbin/obmc-rest\", line 282, in do_post", " return request.route_data['method'](request.parameter_list)", " File \"/usr/lib/python2.7/site-packages/dbus/proxies.py\", line 145, in call*", " _keywords)", " File \"/usr/lib/python2.7/site-packages/dbus/connection.py\", line 641, in call_blocking", " message.append(signature=signature, *args)", "TypeError: Expected a string or unicode object" ] }, "message": "500 Internal Server Error", "status": "error" }rahuls-MacBook-Pro:~ rahulmaheshwari$ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST -d "{\"data\": [{\"ipaddr\":\"9.109.116.67\"}]}" https://9.3.164147/org/openbmc/LogManager/rsyslog/action/Enable { "data": 0, "message": "200 OK", "status": "ok" }rahuls-MacBook-Pro:~ rahulmaheshwari$ curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST -d "{\"data\": [{\"port\": 500}]}" https://9.3.164.147/org/openbc/LogManager/rsyslog/action/Enable { "data": 0, "message": "200 OK", "status": "ok" }rahuls-MacBook-Pro:~ rahulmaheshwari$

bradbishop commented 8 years ago

Just to make sure, is the dbus signature for the parameter of the Enable method a{sv} ?

bradbishop commented 8 years ago

@rahulmah please reopen if you can recreate this.