How can we make it easier for you to develop on top of Wild Apricot?

fieldvalues contact api

I have an interesting issue you can help me with. I am using the Contacts API and calling it from a Javascript call using the WA API wrapper for jQuery. I got this code from the WA developer forum and loaded it into the files section to call locally from the WA install (rather than from the original location).

http://iarpreiki.org/resources/js/waPublicApi.js

I am using the API to create a URL that I will pass to an external SaaS system, so I need to collect various contact/membership field data.

The testing page is at

http://iarpreiki.org/Print-Your-Membership-Certificate -- the top HTML widget is where the HTML/JS code lives. It's quite short.

I am getting the contact JSON object properly returned and can populate the various fields that are coming back into my form, but none of the FieldValues array is coming back. I am expecting all the various extended field values like "Member since" and "Renewal due" as well as all the extra contacts and member fields that have been defined.

Here's the debugger output (link to picture) inspecting the object called "data" - The FieldValues object is totally missing.

https://dl.dropboxusercontent.com/u/55719247/debug%20values%20for%20contacts%20WA%20call.png

What am I doing wrong?

1 vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)

    We’ll send you updates on this idea

    AlexSirota shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    4 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Matthew Thomure commented  ·   ·  Flag as inappropriate

        Sample code:
        https://github.com/matticustard/sample-wild-apricot-js-api

        This should already be set up for your ClientId and the existing source location of the JS file, per your previous code. You should be able to copy and paste from apijs.inc into a Custom HTML gadget on a new page. The response will be printed to the page.

        I was going to post a link to another forum entry regarding the status of this issue, but it looks like you already found it. If you have outside hosting support, I would recommend looking into the Single Sign-On service.

        Best of luck!

      • AlexSirota commented  ·   ·  Flag as inappropriate

        The code below works under an admin but on the first click contactID is undefined, but on the second click it all works perfectly populaing the member since and renewal due on fields in the second call.

        I've confirmed this does not work on a regular, nonadmin account though.

        I get this error in the console: 403 (Current token does not provide access to scope 'contacts_view'.)

        Will this be changed any time soon? Seems like this restricts the type of information available, especially since the me scope does not contain fieldValues (extended member/contact fields) and all standard system membership fields.

      • AlexSirota commented  ·   ·  Flag as inappropriate

        Matthew,

        Thanks for this -- I was not aware of this until now. So then are fieldvalues not available for the me scope? The documentation is confusing on this point as it shows fieldvalues in the sample JSON stream, but now it seems this is only available to the contacts scope according to support?

        Your sample code with getContact would be helpful if you could post here so I can follow.

      • Matthew Thomure commented  ·   ·  Flag as inappropriate

        Are you aware that the JavaScript API will only return the "contacts" scope to an administrator? Regular users are limited to the "me" scope.

        I replicated your code but I couldn't get the contactID variable to pass correctly to the second apiRequest function as it was written. I was able to compensate for this by wrapping the second apiRequest in a new function "getContact(contactID)" and calling this from the success function of the first request.

        Hope this helps!

      Feedback and Knowledge Base