[英]Mindbody API - Getting error while adding client to class (Signup)
I have this code running for accessing Mindbody API. 我正在运行此代码以访问Mindbody API。 This method adds a client to selected class. 此方法将客户端添加到选定的类。 But this is not working and giving me message: 但这不起作用,并给我消息:
"ErrorCode : 201 An action has failed. Please see object message for details." “ ErrorCode:201操作失败。有关详细信息,请参见对象消息。”
public string SignUp(Credentials credentials, string[] clientIds, int[] classIds)
{
var addToclassRequest = new AddClientsToClassesRequest
{
SourceCredentials = new SourceCredentials
{
SourceName = credentials.SourceName,
Password = credentials.SourcePassword,
SiteIDs = credentials.SiteId
},
ClientIDs = clientIds,
ClassIDs = classIds,
Test = true,
RequirePayment = false,
Waitlist = false,
SendEmail = true
};
var c = _classService.AddClientsToClasses(addToclassRequest);
return c.Message.ToString();
}
I dont know why its failing. 我不知道为什么它失败了。 Any help will be highly appreciated. 任何帮助将不胜感激。
You might need to set the request.UserCredentials besides request.SourceCredentials; 您可能需要设置request.UserCredentials以及request.SourceCredentials;。 remove the RequirePayment, Waitlist, set Test = false; 删除RequirePayment,Waitlist,设置Test = false; and make sure the clientId and classId are exist. 并确保clientId和classId存在。
public string SignUp(Credentials credentials, string[] clientIds, int[] classIds)
{
var addToclassRequest = new AddClientsToClassesRequest
{
SourceCredentials = new SourceCredentials
{
SourceName = credentials.SourceName,
Password = credentials.SourcePassword,
SiteIDs = credentials.SiteId
},
ClientIDs = clientIds,
ClassIDs = classIds,
Test = false,
//RequirePayment = false,
//Waitlist = false,
SendEmail = true
};
var c = _classService.AddClientsToClasses(addToclassRequest);
return c.Message.ToString();
}
Since you're not sending any UserCredentials
in your request, you're operating in "Consumer Mode", which typically has a lower level of permissions than "Business Mode", the mode your API call would be in if you passed both SourceCredentials
and UserCredentials
. 由于您没有在请求中发送任何UserCredentials
,因此您在“消费者模式”下运行,该模式通常具有比“业务模式”更低的权限,因此,如果您同时传递SourceCredentials
和UserCredentials
。
I'm not entirely sure, but it could be that if you want to ensure that you don't need to require a payment in order to add a client to a class ( RequirePayment = false
), you may need to run the call in "Business Mode". 我不确定,但是如果您想确保不需要为将客户添加到类中而需要付款( RequirePayment = false
),则可能需要在“业务模式”。
If that doesn't work and you still get back the same error, you should probably confirm that: 如果这不起作用,并且您仍然返回相同的错误,则可能应该确认:
If that still doesn't work, you might want to try passing in a ClientServiceID
aka a Pricing Option ID (I know that this parameter is not documented specifically in the AddClientsToClasses
API call documentation, but you can pass it in; figuring that out was guesswork) for the pricing option that you intend to use in order to pay for a class. 如果仍然AddClientsToClasses
,您可能希望尝试传入ClientServiceID
定价选项ID(我知道该参数未在AddClientsToClasses
API调用文档中专门记录,但是您可以传入;弄清楚您想用来为课程付费的定价选项)。 This takes you down the road of working out a way to make some kind of payment for the class you want to book your client into. 这使您无需再想办法为要预订客户的课程支付某种费用。
Not sure if this will help, but this is the workflow that I found I needed to end up doing in order to get a client booked properly in a class (each of the steps below required an API call): 不确定这是否会有所帮助,但这是我发现最终需要完成的工作流程,以便在类中正确预订客户端(以下每个步骤都需要API调用):
It was quite complicated and took me a long time to finally get working as intended. 这很复杂,我花了很长时间才终于按计划开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.