简体   繁体   English

Mindbody API-将客户端添加到类中时出错(注册)

[英]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 ,因此您在“消费者模式”下运行,该模式通常具有比“业务模式”更低的权限,因此,如果您同时传递SourceCredentialsUserCredentials

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: 如果这不起作用,并且您仍然返回相同的错误,则可能应该确认:

  • You have a valid client ID 您有一个有效的客户ID
  • You have a valid class ID 您有一个有效的班级ID

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调用):

  • Retrieve or create the MindBody client ID for the user I want to book in 为我要预订的用户检索或创建MindBody客户端ID
  • Retrieve the MindBody class ID of the class to book the client into 检索该类的MindBody类ID,以将客户端预订到
  • Retrieve all the Service Categories (aka Program IDs) from the MindBody site and choose the one that contained the Pricing Option I would be using to pay for the class 从MindBody网站检索所有服务类别(即程序ID),然后选择包含我将用于支付课程的定价选项的服务类别
  • Retrieve all the Pricing Options (aka Client Service IDs) that the client is able to use, and choose an appropriate one 检索客户端可以使用的所有定价选项(也称为客户端服务ID),然后选择一个合适的选项
  • Retrieve the list of payment methods and extract the ID of the one I intended to use 检索付款方式列表,并提取我打算使用的付款方式的ID
  • Purchase a pricing option for the client using the the client ID, pricing option ID, and payment method ID 使用客户ID,定价选项ID和付款方式ID为客户购买定价选项
  • Retrieve the ID of the purchased pricing option using the client ID and class ID, and then use the service category ID from earlier to make sure the pricing option is the right one 使用客户ID和类别ID检索购买的定价选项的ID,然后使用之前的服务类别ID来确保定价选项是正确的
  • Add client to the class using the IDs of the client, class, purchased pricing option 使用客户ID,班级,购买的定价选项将客户添加到班级中

It was quite complicated and took me a long time to finally get working as intended. 这很复杂,我花了很长时间才终于按计划开始工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM