[英]How I can get all Clients with MindBody API python
I am trying to get all clients using MindBody API , I tried this, 我正在尝试使用MindBody API获得所有客户端 ,我尝试了这个,
from suds.client import Client
from Helper.ClientService import ClientServiceMethods
# Making a call
calls = ClientServiceMethods()
result = calls.GetAllClients()
client_dict = Client.dict(result)
clients = client_dict['Clients']
client_list = clients.Client # transferring clients into a python list
#printing the lenght of received clients list
print len(client_list)
the above code will work but the issue is that it will not pull of more than 27 client, that's it. 上面的代码可以工作,但问题是它不会吸引超过27个客户端,仅此而已。 from MindBody Docs the GettAllClients should get up to 1000 client, the limit for a call is 1000 which means i can get up to 1000, but the problem is that I am note able to get at least that 1000, I am only getting 27 clients.
从MindBody Docs的GettAllClients应该最多可以容纳1000个客户端,一个呼叫的限制是1000,这意味着我最多可以容纳1000个客户端,但是问题是我注意到至少能够获得1000个客户端,而我只能获得27个客户端。
Note: I am working with Demo Data, Sandbox which can anyone look them, I used the Sample code from their MindBody Python repository
注意:我正在使用演示数据,沙箱,任何人都可以看它们,我使用了MindBody Python存储库中的示例代码
I am working on getting all clients data through the api,these clients can viewed from here 我正在通过api获取所有客户端数据,这些客户端可以从此处查看
Username: Siteowner | 用户名: Siteowner | Password: apitest1234
密码: apitest1234
for anyone who's having problems with this too, this will be a big help for you. 对于任何对此也有疑问的人,这将对您有很大帮助。
when we make call GetClients, mindbody will send clients but it will represent them in form of pages so that 25 client was the first page if u want to get the next 25 client you would have to call the page indexed 2 and so on and so forth.
当我们打电话给GetClients时,心体将发送客户端,但它将以页面的形式表示它们,因此如果您想获得下一个25个客户端,则25个客户端是第一页,您必须调用索引为2的页面,依此类推向前。
in code this is how u would do this, using API Example code ClientService
, do this inside the method GetClientsByString 在代码中,这就是您将如何使用API示例代码
ClientService
执行此操作,该方法在GetClientsByString方法中进行
def GetClientsByString(self, searchStr):
"""Convenience method to find clients containing searchStr in their name or e-mail."""
request = self.CreateBasicRequest("GetClientsRequest")
# Since SearchText is just a string, we can assign it directly.
request.SearchText = searchStr
request.CurrentPageIndex = 1 # increase this number by one each time
return self.service.service.GetClients(request)
This is how I approached it; 这就是我的处理方式; very open to a better way that's not as API intensive:
非常开放,可以找到一种不占用大量API的更好方法:
clientService = ClientServiceCalls()
#get all client IDs
clientResponse = clientService.GetClientsByString('')
clientList = clientResponse.Clients.Client
clientVisitsDict = []
for c in clientList:
#Call get ClientVisits API on each Client ID
clientResponseVisits = clientService.GetClientVisits(str(c.ID))
if clientResponseVisits.Visits:
visitsList = clientResponseVisits.Visits.Visit
for v in visitsList:
### your code here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.