I'm trying the following:
from wialon import Wialon
from wialon import WialonError
try:
wialon_api = Wialon()
result = wialon_api.token_login(token=token)
wialon_api.sid = result['eid']
params = '{"spec":{"itemsType":"avl_unit","propName":"sys_name","propValueMask":"*","sortType":"sys_name"},"force":1,"flags":1,"from":0,"to":0}'
result = wialon_api.call('core_search_items', params)
wialon_api.core_logout()
print str(result)
except WialonError as e:
print str(e)
I get WialonError(Invalid input core_search_items (4))
error. When using Postman with this same params, I get the response which I expect.
I have also tried the following params
, i.e. as python dict:
params = {
"spec": {
"itemsType":"avl_unit",
"propName":"sys_name",
"propValueMask":"*",
"sortType":"sys_name"
},
"force":1,
"flags":1,
"from":0,
"to":0
}
But I get the same result.
After studying the code, I can see that urlencode
might be causing the problem, since it converts the following:
{
'svc': 'core/search_items',
'params': {
"spec":{
"itemsType":"avl_unit",
"propName":"sys_name",
"propValueMask":"*",
"sortType":"sys_name"
},
"force":1,
"flags":1,
"from":0,
"to":0
},
'sid': 'foo42'
}
to
params=%7B%27flags%27%3A+1%2C+%27force%27%3A+1%2C+%27spec%27%3A+%7B%27sortType%27%3A+%27sys_name%27%2C+%27itemsType%27%3A+%27avl_unit%27%2C+%27propName%27%3A+%27sys_name%27%2C+%27propValueMask%27%3A+%27%2A%27%7D%2C+%27to%27%3A+0%2C+%27from%27%3A+0%7D&svc=core%2Fsearch_items&sid=foo42
What am I doing wrong? or is there a bug in the library?