Method Community

 

Using API with Multi-Tenancy

Last post 10-15-2012 5:39 PM by Matt. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 10-13-2012 11:23 AM

    • Matt
    • Top 10 Contributor
    • Joined on 11-03-2008
    • Posts 877

    Using API with Multi-Tenancy

    What is the reccomended approach for using the API with a multi-tenancy account?

    For example if I want to insert a Campaign for a tenant.

    If I try using the tenant Company Account for the strCompanyAccount parameter I get an authentication error, which probably makes sense since the record should be added to the head-office account and have the TenantID field set accordingly. However, that doesn't work either since the TenantID field does not support add or edit.


    Matt Raiser

    Founder,



    www.techinthefield.com

    matt@techinthefield.com

    219-221-9500



    ~ Method user / partner since 2008

    ~ Over 15 years field service experience

    ~ 2013 Method Partner of the Year

    ~ Degree in Computer Science





    Creator of:


        


  • 10-14-2012 7:38 AM In reply to

    Re: Using API with Multi-Tenancy

    Hey Matt - hope all is with you, it's been a while!

    The TenantID should not be read-only.

    Does the user you are authenticating with have access to that Tenant? i.e. are you able to sign into Method normally to that Tenant with the user name and password/sessionid you are specifying in your request?

    Also, are you sure that the account you are doing this to is a multi-tenant account? i.e. if you have a sandbox account that you are using to test things out for your client, you should make sure that the sandbox account has been converted to multi-tenancy as well (you need to email us so that we can run the conversion).

    Cheers,

    Paul

  • 10-15-2012 8:53 AM In reply to

    • Matt
    • Top 10 Contributor
    • Joined on 11-03-2008
    • Posts 877

    Re: Using API with Multi-Tenancy

    Hey Paul,

    Things are good here, hope all is well with you too.

    I ran my code after your reply so that I could copy and paste the exact response I was getting and it was successful!

    Are you sure you didn't change the properties for the TenantID field? Stick out tongue


    Matt Raiser

    Founder,



    www.techinthefield.com

    matt@techinthefield.com

    219-221-9500



    ~ Method user / partner since 2008

    ~ Over 15 years field service experience

    ~ 2013 Method Partner of the Year

    ~ Degree in Computer Science





    Creator of:


        


  • 10-15-2012 9:12 AM In reply to

    Re: Using API with Multi-Tenancy

    Nope. If that wasn't already working like that we'd have some big issues!!

    Paul

  • 10-15-2012 3:13 PM In reply to

    • Matt
    • Top 10 Contributor
    • Joined on 11-03-2008
    • Posts 877

    Re: Using API with Multi-Tenancy

    You make a good point!

    I didn't see anywhere in CreateMethodUserV2 that would allow me to set which franchisee a new user is associated with. Am I just missing it? Or is it something that could be added?



    Matt Raiser

    Founder,



    www.techinthefield.com

    matt@techinthefield.com

    219-221-9500



    ~ Method user / partner since 2008

    ~ Over 15 years field service experience

    ~ 2013 Method Partner of the Year

    ~ Degree in Computer Science





    Creator of:


        


  • 10-15-2012 3:41 PM In reply to

    • Matt
    • Top 10 Contributor
    • Joined on 11-03-2008
    • Posts 877

    Re: Using API with Multi-Tenancy

    I was able to insert records into the Campaign table, but when I use the same exact code and only change the table and the field/value arrays parameters, I get the following response:

    <?xml version="1.0" encoding="windows-1252" ?><MethodAPI response = "The field TenantID does not support add." ></MethodAPI>

    Any ideas why I would get this error one one table, but not another?


    Matt Raiser

    Founder,



    www.techinthefield.com

    matt@techinthefield.com

    219-221-9500



    ~ Method user / partner since 2008

    ~ Over 15 years field service experience

    ~ 2013 Method Partner of the Year

    ~ Degree in Computer Science





    Creator of:


        


  • 10-15-2012 4:14 PM In reply to

    Re: Using API with Multi-Tenancy

    Depends on the table. Which table is it?

  • 10-15-2012 4:24 PM In reply to

    • Matt
    • Top 10 Contributor
    • Joined on 11-03-2008
    • Posts 877

    Re: Using API with Multi-Tenancy

    Sorry, I meant to include that, CampaignStatus is the table I am getting the error on.


    Matt Raiser

    Founder,



    www.techinthefield.com

    matt@techinthefield.com

    219-221-9500



    ~ Method user / partner since 2008

    ~ Over 15 years field service experience

    ~ 2013 Method Partner of the Year

    ~ Degree in Computer Science





    Creator of:


        


  • 10-15-2012 5:22 PM In reply to

    Re: Using API with Multi-Tenancy

    Matt - I just regenerated all the field definitions on the account in question.

    I have a hunch as to why they weren't generated the first time. 

    Can you try now?

    paul

  • 10-15-2012 5:23 PM In reply to

    Re: Using API with Multi-Tenancy

    ...and I bet the reason the Campaign worked was because you went into Customize > Tables / Fields and hit Finish Editing fields between your original post and my response that it 'should work'.

    Sound about right? 

    Paul

  • 10-15-2012 5:39 PM In reply to

    • Matt
    • Top 10 Contributor
    • Joined on 11-03-2008
    • Posts 877

    Re: Using API with Multi-Tenancy

    Yup, it works now, and yes, I probably hit finished editing fields. I was wondering why the TenantID field wasn't showing up in there. It is showing up now.

    Did you see my earlier post about the CreateMethodUserV2 call?

    Thanks for getting the account straightened out.


    Matt Raiser

    Founder,



    www.techinthefield.com

    matt@techinthefield.com

    219-221-9500



    ~ Method user / partner since 2008

    ~ Over 15 years field service experience

    ~ 2013 Method Partner of the Year

    ~ Degree in Computer Science





    Creator of:


        


Page 1 of 1 (11 items)