NationBuilder is hiring

We're looking for software developers who want to change the world. Click here to learn more and apply.

Loading

API Developers Forum

We're thrilled to see all the great development going on with the NationBuilder API, and want to open this forum up for public feedback, helps and hints, questions and more. This resource is curated by VP of Business Development Adriel Hampton and the API Team - our goal is developers helping developers, so we definitely want to hear from you. You can also use the tags to rank posts. Thanks!

Sort by

Which fields are writeable in People API?

Is there any documentation on which fields are actually writeable in the People API? 

So far I have been having to find this out by trial and error, and have discovered that the page_slug and address : lat/lng fields can't be written to. 

Which other ones can't be written to? 

Add your reaction Share

500 Error with PHP OAuth

I'm having an odd problem with the API. I wrote a script which was working fine in early August, but when I returned to using it I now get a 500 error when generating a token. If I make a new app, it will generate a token fine once but any repeated executions will return a 500. I haven't changed anything, and it was worked fine before. Help?

NB doesn't seem to have a good way to post code, but here's the blog post I wrote a few weeks ago with my code: http://www.richiroutreach.com/blog/working-php-and-nationbuilder-api

// OAuth 2 Library
require_once ROOT . '/OAuth2/Client.php';
require_once ROOT . '/OAuth2/GrantType/IGrantType.php';
require_once ROOT . '/OAuth2/GrantType/AuthorizationCode.php'; 

// Client ID and Secret from Nation Builder 
const CLIENT_ID = 'id';
const CLIENT_SECRET = 'secret';

// Constants we need to talk to Nation Builder
const REDIRECT_URI = "http://example.com/create_user.php";
const AUTHORIZATION_ENDPOINT = "https://xxx.nationbuilder.com/oauth/authorize"; 
const TOKEN_ENDPOINT = "https://xxx.nationbuilder.com/oauth/token";
const REQUEST_ENDPOINT = "https://xxx.nationbuilder.com/api/v1";

// Start a new OAuth2 Client 
$client = new OAuth2\Client(CLIENT_ID, CLIENT_SECRET); 

// Check if we have an authorize code, if not obtain one 
if (!isset($_GET['code'])) { 
     // Generate the URL we need to go to get the token 
     $auth_url = $client->getAuthenticationUrl(AUTHORIZATION_ENDPOINT, REDIRECT_URI); 

     // Redirect to that URL (which then sends us back to the REDIRECT_URI with a code, IE this page) 
     header('Location: ' . $auth_url); 

     // End this process 
     die('Redirect'); 
} 

// We have a code, so generate the parameters we need to get an access token 
$params = array('code' => $_GET['code'], 'redirect_uri' => REDIRECT_URI); 

// Obtain our access token 
$response = $client->getAccessToken(TOKEN_ENDPOINT, 'authorization_code', $params);
2 reactions Share

description for the last_call_id does not make sense

  • last_call_id - the time and date of the last call to this person

Is that correct description? Looking at other field it should be 'last_call_at'. 

1 reaction Share

cannot update neither contact_method_id nor call_status_id

Hello,

We are posting those fields as following, but when read back the call_status_id field does not exist or empty and contact_status_id shows  the old value.

"call_status_id": "4",

"contact_status_id": "3"

Add your reaction Share

updated_at and contacted_at issues and etc.

Hello,

We are posting update as following, however do not see the note's time-stamp as posted. The note time always says "5 days ago". Also we do not see 'contacted_by' on the page.


{

"person": {
"updated_at": "2014-08-26T14:57:16-04:00",
"last_contacted_at":"2014-08-26T14:49:27-04:00",
"last_contacted_by ": { "id": "XXX" } ,
"note_updated_at": "2014-08-26T14:49:27-04:00" ,
"note": "Hello again!"
}

}

Add your reaction Share

How to set 'last_contacted_by'

We are trying to set this field on update. We set id to an existing person is, however do not see this was reflected on the updated person page.

"last_contacted_by ": { "id": "XXX"  } 

 

Also, 

 

 

2 reactions Share

Issue with PUT'ing to people via API with PHP

Hi,

 

We're using the NB people API with PHP and the adoy/oauth2 library. Recently, whenever our site makes a PUT to /api/v1/people/push, we seem to be receiving a code 400 error with no message attached. 

 

Code:

 

$payload = array(
'person' => array(
'first_name' => $first_name,
'last_name' => $last_name,
'email' => $email,
'note' => 'Sign up from web form at ' . DB::now(),
'email_opt_in' => true
)
);

 

$api_url = $baseApiUrl . '/api/v1/people/push';

$response = $client->fetch($api_url, $payload, 'PUT', array('Content-type' => 'application/json', 'Accept' => 'application/json'));

The response comes through like this:

(

    [result] => 

    [code] => 400

    [content_type] => text/plain; charset=utf-8

)

 

Can anyone point me in the direction of what isn't right here?

 

Thanks,

Sam

1 reaction Share

How update Call/Data Entry view fields for LIsts via API

Hello,

 

I am trying to figure out how to update via API the Data Entry and Call view fields for a List.

Also what are corresponding fields in the people API?

 

Thanks.

1 reaction Share

Reports dashboard with number count of prospects in a filter?

I'm interested in creating a status page with a live count of the number of people in a given filter.

For example: Team A is responsible for getting prospects from a specific area to join a nation.  A filter is created that shows 'joiners' from that specific area.

I want to create a page that then shows (live) the number of supporters in a specific filter.  I would then be able to show this for multiple teams to compare/contrast their progress.

In the API Explorer I saw there's something for lists (which aren't dynamic) but not filters...

Can this be done?Thanks for any help with this.

1 reaction Share

Validation Error when Setting Membership Expiration Date to NULL

I'm attempting to use the new Membership API to update membership records.  We have a class of members whose memberships do not expire, but whose membership records were erroneously given an expiration date.

When I use the API to update the membership expiration date to NULL, I throw a validation error.

PUT /people/:person_id/memberships

{
  "membership" : {
    "name" : "Standard"
    , "status" : "active"
    , "expires_on" : null
  }
}

Any thoughts on how to fix?  I'm considering just setting the expiration date 100 years in the future, but that could upset queries for members without expiration dates.

 

Add your reaction Share

Can't create a new contact; getting validation error

I'm trying to create a contact record but am getting a validation error:
HTTP POST (301.95ms) https://ertw.nationbuilder.com:443/api/v1/people/12456/contactsRequest body   {"contact":{"sender_id":3,"status":"answered","method":"door_knock","type_id":2,"note":null}} Response status   Net::HTTPBadRequest (400)Response body   {"code":"validation_failed","message":"Validation Failed.","validation_errors":["recipient_id can't be blank"]}
recipient_id is listed as an optional attribute in the docs and it seems redundant since I'm passing the recipient in the url, but I'll play along:
HTTP POST (747.43ms) https://ertw.nationbuilder.com:443/api/v1/people/12456/contactsRequest body   {"contact":{"sender_id":3,"recipient_id":12456,"status":"answered","method":"door_knock","type_id":2,"note":null}} Response status   Net::HTTPBadRequest (400)Response body   {"code":"validation_failed","message":"Validation Failed.","validation_errors":["recipient_id can't be blank"]}
I'm using code that used to work (and didn't need recipient ID). I've also tried this in the API explorer and get the same results.
Any advice?
Thanks,
Sean
1 reaction Share

People Credentials

Hello I'm wondering if there is a way to use the people credentials from a nation into my application. 
I mean, is it possible that people from my nation logs in my app with their nationbuilder credentials (user and password)? 
I saw an app called oneclickpolitics which ensures that "NationBuilder customers can very Quickly and Securely login using their NationBuilder accounts." 
How can I do that? Am I missing some functionality from the nationbuilder API? As far as I know, the people endpoint returns no credentials. 
I would really appreciate any suggestions or help.
Thank you!
2 reactions Share

POST/PUT endpoints do not work.

I'm using the NB api via PHP. The GET/DELETE methods both work but no matter what I try I can not edit or add a new people resource using the client->fetch() function.

The error code is always a 400 no matter how I format the parameters. Please help and don't give me a canned response to the API helper because I've spent 3.5 hours already trying various things in the documentation which is thin to say the least.

12 reactions Share

App Integration Leading Practices?

I'll frame this question in a general way so it applies to other 3rd party app developers, not just me:

What level of API integration are NB customers asking for?

For example, if you build a third-party app that can help members of a nation interact with each other (i.e. group chat or something else), there are several ways I can imagine that you'd want to integrate it with NB, each with a different level of complexity:

  • No integration: Just listing an app in the app directory, essentially as an ad for the app-- probably not an option.
  • Minimal integration: Include the app in an iframe and have either no sign-in requirement or require that the members of the nation sign in a second time within the app's iframe as part of the app's authentication process.
  • Deep integration: Connect to the People API so that members of a nation can sign into your app from within a NB page for that nation.
  • Other options?

Are any of those options emerging as common or recommended?  

What are NB customer expectations around 3rd party app integration?  I don't expect they'd be too happy with requiring that the members of their nation sign in twice-- once to NB and once to the app.  That's what I found with one client I worked with.

Thanks!

1 reaction Share

What kind of apps do NB clients need but do not have yet?

As a third-party app builder, I'm wondering what the NB staff hears about "apps NB customers wish they had."  

I figure this is a good question to throw out there in the open, because many of the app developers on this list could benefit from hearing some advice about the unmet needs of current NB customers.

1 reaction Share

Please give us the ability to highlight streets without bubbles!!!

All I want in the whole world right now is to have the ability to give people walk maps without bubbles, and with highlighted streets. Too many bubbles on a street makes for an almost unreadable street map. 

I've even seen walk maps with directional arrows for people. Google maps used to have a tool for this. Would this be something NB could activate or employ? 

 

 

Add your reaction Share

People API Membership Creation

I've used the People API to sync members between another system and NB but the API doesn't appear to set memberships on the new person record.  Even with membership_level_name set no corresponding membership record is created for that person.

Furthermore no error is given if a non-existent membership type is specified.  Is the people API not capable of creating memberships, am I doing it wrong, or has something changed?

2 reactions Share

OAuth Callback with App Id

When receiving the code parameter in our oauth callback page, can you also pass the nation slug and appname or client id with that code so we know which nation/app the request came from? This would allow us reuse code in many places on our side. I tried adding url parameters to my oauth callback url, but the app form would not allow it. Thanks!

 

Update: Nevermind. I can't put url params in the callback url, but I can put params in the redirect_uri to be passed back to me. Thanks!

Official response from completed

Scott, our CTO's recommendation is you use cookies to to track users and sessions - so, set a cookie when someone first lands on your site, and with each subsequent request (even redirects back to the site) they will submit the same cookie. This is the standard way that websites verify that the user behind request A and request B are the same person.

if you use Rails, you get sessions out of the box, and if your person is known to your app you can just say current_user.id or whatever and you don't need to know about cookies or sessions.
2 reactions Share

Delete Tag endpoint

It would be useful to be able to delete a tag (from the system - not from a person) through the API. 

We have an external app that generates a lot of tags that are used for a short time. After a while this clogs up the list of tags with unused ones. 

Add your reaction Share

Required JSON format structor

Hi,

I am very curious as how you guys know what fields are required for any JSON format. There is no example of what is required or not. Can anybody shed some light?

Thanks.

 

Ryan

1 reaction Share

A question about Sign Up pages.

Hi All,

We use the Victory theme.The sign up demands that the single line address is filled. We don't want that as we have custom fields to collect addresses. So how do I edit the page to not require the single line address box be filled? I expect it has some thing to do with the code below. By the way we will be getting rid of any way for the members to log in.

{% if page.signup.is_all_info_collected? == false %}
                  {% if request.sorta_logged_in? %}
                    {% submit_tag "Update info", class:"submit-button" %}
                  {% else %}
                  {% submit_tag "Signup", class:"submit-button" %}
                {% endif %}
              {% endif %}
             


      
            {% endform_for %}

Add your reaction Share

Criteria for External ID on Survey

I've been trying to specify and external id for my surveys. Sometimes if a really obvious one is chosen (e.g. 4) I get told that this has already been taken. When I pick a non-obvious one there is no error but the external_id fails to be reflected in the survey.

I don't know if this is a big or there's just some criterion that I'm missing for what constitutes a valid external_id.

Add your reaction Share

Remove Questions

I thought questions where associated with a specific Survey (given that that's how they're added via the API). But when I delete a survey the questions persist.

Is there any way to delete questions?

Add your reaction Share

php

2 reactions Share

Setting page_slug through People API

Hi, I'm trying to set the page_slug field of a person in the People API, by making a PUT request to the Update People endpoint

/api/v1/people/{id}

with the body 

{ "person" : { "page_slug" : "{slug}" } }

to change the page slug of the person with ID {id} to {slug}. 

It's coming back with '200 OK' and returns the record of that person, but it refuses to update the page_slug field. 

I know it is not usual to update that field, but for my purposes I need to. Is it not implemented by the API? or am I doing something wrong?

regards

Nik

Add your reaction Share

Bug tracker

I think NB needs a bug tracker. Is there one I'm missing. Currently, we report bugs via point people or by developer email addresses that we happen to have. This system does not work for a variety of reasons. 

I've reported many bugs via point people, and mostly they are misunderstood or ignored. I am sitting on about a dozen low or medium priority bugs that I'd happy report, but since I can only do so through point people I only report major, show-stopping bugs. And even then they usually don't get through to the engineers until I start squeaking. 

A professional bug tracker that the engineering team can directly access, without point people as gate keepers, is important. 

Official response from completed

Hi Brad,

We do have a system for tracking bugs which you can submit to from the Control Panel of your nation without having to contact your point person or a developer directly. These reports are reviewed by our engineers and technical staff daily. To report a bug, click on "Support" at the bottom-right of any page in the Control Panel and select "Report a problem." You will then be guided through several steps to take a screenshot and add any additional comments that would aid in reproducing and/or troubleshooting the issue.

Report a bug

14 reactions Share

API: DELETE /lists/:list_id/listings/:person_id => 404 response for person in the list.

 

using this command (all variables in {} are substituted in):

curl -X DELETE --header "Content-Type: application/json" --header "Accept:application/json" https://{MY_SLUG}.nationbuilder.com/api/v1/lists/{THE_LIST}/listings/{MY_ID}?access_token=...

i get a 404 response even though the person is in list (previously checked using api explorer).

 

can you please fix this? 

5 reactions Share

Does Nationbuilder have a Rails 4 API gem in the works?

Really excited about all the new features coming out of NationBuilder's labs, am already starting to play with a few of them and have had some great successes. But, I'm sure I'm not the only Rails developer who's having a hard time organizing everything without a robust gem.
So, question for the NationBuilder dev team, and the larger developer community as a whole:
Do you guys have plans to make a Rails 4 gem for NationBuilder's API? It would be a really great way to streamline access to NB, and make it easier for developers to make applications that tap into the platform's potential. I see that ActionSprout has a Rails 3 gem on github, https://github.com/bellport/nationbuilder/. It's super-cool, but it uses an older version of Rails, is missing a number of components, and hasn't been updated in a while.
I was thinking of taking a stab at creating one. Haven't figured out the parameters of the gem itself, just that there's a need. Before moving forward on this though, I wanted to see if someone already has one in the works so we don't duplicate efforts? Or maybe there's room for collaboration?
Thanks!
4 reactions Share

/events/:id has Contact.phone missing 1st number

Ive tested this in the API explorer as well as with the following command line invocation:

curl -X GET --header "Content-Type: application/json" --header "Accept: application/json" https://agv.nationbuilder.com/api/v1/sites/agv/pages/events/\?id\=...\&access_token=...

 

Both produce contact phone numbers with the first number missing

e.g. 0411222333 is given as 411222333

Viewing the event via http://victoria.greens.org.au/ocean_grove_doorknock_and_snack 

we see that the correct, full phone number is displayed.

Can you please fix this?

2 reactions Share

Recording Pledge Data via the API

I'm working for a non-profit that is running a pledge drive, and has pledge form on its website.  Is there any way we can move pledge data into NationBuilder via the API?  I don't see pledges referenced anywhere in the documentation.

1 reaction Share

How to set the featured content

I'm trying to import a few Wordpress sites using the API.  On each of them every blog post has a header image.  The equivalent in NationBuilder would be to add a signle featured content slider to each page, but I don't see anything in the API to do this.  Am I missing something?  If this can't be done, is there a way to set HTML before the content_before_flip?

1 reaction Share

How to get client id and api secret

How to get client id and api secret

Official response from completed

Steps 3 and 4 of our API Quickstart guide describe how to obtain a client ID and API access token:

http://nationbuilder.com/api_quickstart

2 reactions Share

Subscribe to list widget

I want to add a box to my site that allows users to sign up for a mailing list that we are now migrating to NationBuilder. 

My site is Python/Django. I have this already set up with Mailchimp.

The Python Quickstart doc doesn't explain what the variables 'code' or 'REDIRECT_URI' are or how they should function in step 4. 

This should be pretty basic functionality. Am I missing something? Is there a simpler way to implement this?

 

Official response from completed

Brett, for a single-nation use, just use an app test token - you can find that in your nation's control panel under Settings > Apps.

2 reactions Share

Deleted/Merged webhook

This is needed to ensure proper cotnact synchronization between an external database and NationBuilder. You can delete from NB, but no webhook fires when data is removed or merged.

1 reaction Share

People API Update endpoint always errors

I'm using the Update endpoint, with the request straight from the documentation:

curl 'https://[nation].nationbuilder.com/api/v1/people/[id]?access_token=[token]' -X PUT -H 'Content-Type: application/json' -d '{"person":{"first_name":"Joe","email":"johndoe@gmail.com","phone":"303-555-0841"}}'

I receive this response:

{"code":"server_error","message":"You have encountered a server error."}

This is after creating a record using the People Create endpoint, and verifying the record is available with the People Show endpoint.

Any help appreciated.

1 reaction Share

People API fails to create address resources

I'm using the Create endpoint, with the request straight from the documentation:

curl 'https://[nation].nationbuilder.com/api/v1/people?access_token=[token]' -X POST -H 'Content-Type: application/json' -d '{"person":{"email":"bob@example.com","last_name":"Smith","first_name":"Bob","sex":"M","employer":"DexterLabs","party":"P","registered_address":{"state":"TX","country_code":"US"}}}'

I receive a full response body, but with

"registered_address":null

Any help appreciated.

2 reactions Share

Pulling statistics from the API

I'm trying to display some data from our campaign on a dashboard (http://shopify.github.io/dashing/) by pulling the information through the API. I'm able to get the total number of people from the People index resource, but can't figure out how to do anything more complicated, such as the number of people with a support level of 1 or 2. I have a filter in my control panel for it but the closest I can get would be to add those people to a list and query that, which isn't dynamic.

Any thoughts or pointers?

Thanks.

2 reactions Share

Donation Synchronization, and Donation Search Endpoint

For my organization's use case, we need a synchronization of all donation records, in order to produce financial reports, and for other uses.  This requires high reliability of the synchronization process.

  1. Webhooks provide a synchronization potential with the downside that, like webhooks of other internet-based services, there is almost no feedback about webhook invocation failures.  This makes not meet the requirements of our use case.
  2. Querying the table of donation records as a replacement, or a verification procedure, of the webhook method would be workable.  However, since donations do not currently provide a search endpoint with an "updated_since" parameter, this creates the problem of having to download the whole donation table each time a synchronization is required.  This limitation makes the method virtually unusable for production employment in our use case.

Could you lift any of these limitations, or is there another way to solve this problem.  Again, we have the legal necessity of not missing any records, or misrepresenting any record fields.

Thanks,

--

Pav

1 reaction Share

Request for a webhook on petition signature

This would be radical.  Thanks!

1 reaction Share

People Update server error

I'm trying to update a supporter record and running in to a 500 error.

I did a PUT request to
https://[nation].nationbuilder.com/api/v1/people/[id]?access_token=[token]
using the data:
{"person":{"first_name":"Jane","last_name":"Smith","phone":"123-456-7890"}}

This is the response:
HTTP/1.1 500 Internal Server Error
Date: Wed, 09 Apr 2014 14:38:59 GMT
Server: Apache/2.2.22 (Ubuntu)
X-UA-Compatible: IE=Edge,chrome=1
Cache-Control: no-cache
Nation-RateLimit-Limit: 15000
Nation-RateLimit-Remaining: 14978
Nation-RateLimit-Reset: 1397088000
X-Request-Id: 61ca028a58830a98d0c83ce60c18d079
X-Runtime: 0.532239
X-Rack-Cache: invalidate, pass
X-Powered-By: Phusion Passenger 4.0.23
Status: 500 Internal Server Error
Vary: Accept-Encoding
Content-Type: application/json
Via: 1.1 nationbuilder.com
Connection: close
Transfer-Encoding: chunked
{"code":"server_error","message":"You have encountered a server error.","inner_error":{"name":"NoMethodError","message":"undefined method `strip' for nil:NilClass"}}

 

The same data POSTed to the create endpoint successfully created a supporter, and I'm using the same function to PUT tags.

Any ideas what could be causing this?

Add your reaction Share

People Create Endpoint and PHP.

Hello, I am trying to create an application with People Create Endpoint and the PHP API.
'Get Peoples' works perfect but when I try to add a new person in my Nation, the problems begin.
My token is valid, because I tested it with the new API Explorer tool.
My example with GET is:
$ token = ' MyToken ';
$ client -> setAccessToken ($ token );
$ response = $ client -> fetch ( $ baseApiUrl '/ api/v1/people /'. )
print_r ( $ response );

This shows all the Peoples in my nation.
And this is the example I'm using with POST:
$ token = ' MyToken ';
$ client -> setAccessToken ($ token );
/ *
$ data = array (
    'person ' = > array (
        'email' = > ' bob@example.com ' , " last_name " = > " Smith ", " first_name " = > "Bob"
    )
) ;
$ data_string = json_encode ( $ data );
$ response = $ client -> fetch ( $ baseApiUrl '/ api/v1/people / ', $ data_string , "POST" . )
print_r ( $ response );
I'm not getting any response neither in the browser nor in the curl_request_info file.
What is wrong with my code?
I'm using Ryan Morgan's library ( https://github.com/RyanMorgan/PHP-OAuth2 ) .
I hope someone can help me or show me one example of how to do a POST Request for People correctly?
Thank you very much!
5 reactions Share

Set date when awarding social capital

I would like to be able to set the date when awarding social capital. More importantly I would like to do this through the API.

The reasoning for this is that if we manually award SC for somebody who volunteered to work a shift at one of our events, we would like the date that the SC was awarded to be the same date as the event. We actually have a backlog of SC that I was planning on importing using the API and just realized that I can't set the award date.

 

Add your reaction Share

Events API "guests_count" parameter clarification

Posted this on the Events API page (http://nationbuilder.com/events_api) but thought I should post here as well:

For the guests_count parameter, what is the API referencing? When you create an event, you have the option to do a simple RSVP and include +1s. However, if you have ticket sales, you purchase a number of tickets. Does guest_count reference +1s or number or tickets, or both? Ideally, it would great if it’s both!

Add your reaction Share

Test Token Example

You have great examples on how to navigate the minefield that is OAUTH, but now that you have test tokens, I'd like to see some simple example code on how to use the test token (python/php or even curl).

Thanks
Dennis

Official response from completed

curl https://[slug].nationbuilder.com/api/v1/people/search?access_token=[my test token here] -X GET -H “Content-Type: application/json” -d ‘{"first_name":"Arion"}’ 

2 reactions Share

Searching people returns invalid json format error

I am searching people using this url:

https://malaysia.nationbuilder.com/api/v1/people/search?access_token=my_tokken

with header "Content-Type: application/json" and with following request body:

{"first_name":"abc"}

but it gives me error that json format is invalid

 

Official response from completed

You can accomplish this search with a cURL command wrapping your JSON into the URL. See below for the command you can run in Terminal:

curl https://malaysia.nationbuilder.com/api/v1/people/search?access_token=[my test token here] -X GET -H “Content-Type: application/json” -d ‘{"first_name":"abs"}’ 

3 reactions Share

How to save access token in PHP?

I've tried saving the access token as a key/value pair in the $_SESSION variable, but if

a) I encrypt it and then save it, on the next page or request, it has changed or 

b) I don't encrypt it and save it as a string, it is deleted from $_SESSION on the next page.

 

What am I doing wrong here? I need to make multiple requests in sequence and have a feeling I shouldn't need to ask for a new access token with each one. Thanks!

Official response from

Can you paste the code?

I have a few questions here

1) Why are you encrypting the access token?

2) When you say "save" you just as a session variable or are you saving to a DB?

3) How are you saving it to $_SESSION and do you have this issue with any other variables?  If so check your PHP version because $_SESSION and other register globals were deprecated in 5.3 and removed in 5.4  

I would guess you are doing something like (see below)

<?php

session_start();
$_SESSION['token']=<access token here>;

?>

If you are losing your the value on the next page perhaps you are not passing a session identifier and calling session_start which would cause a new session to start.

4 reactions Share

PUT to people API via PHP

When i do something link this in PHP:

$params = array(
    'person' => array(
      'email' => 'test@email.com','home_address' => array('country' => 'Germany', 'zip' => '66666' ))
);

$header = array('Authorization:' => $token,'Content-Type:' => 'application/json', 'Accept:' => 'application/json');
$response = $client->fetch($baseApiUrl . '/api/v1/people/push?access_token=myaccesstoken', $params, 'PUT',$header);
print_r($response);

i get the following response

Array
(
    [result] => Array
        (
            [code] => missing_parameters
            [message] => Missing Parameters.
            [parameters] => Array
                (
                    [0] => person
                )

            [inner_error] => Array
                (
                    [name] => Api::Error::MissingParameters
                    [message] => Missing parameters: person
                )

        )

    [code] => 400
    [content_type] => application/json
)

 

Whats wrong with the Parameters? Do i need to add something else to the Params?

 

 

 

Official response from

Alexander, I sent you an email with a proposed solution; let me know if that works for you.

thanks, Arion Hardison

 

11 reactions Share

Missing membership fields in People API

I want to synchronise our civicrm membership records with NationBuilder. But the People API does not have any fields for membership level, start or end dates. 

Any chance in including every possible People field in the People API?

Official response from started

David, thanks for your suggestion - and yes, we're working on a massive expansion to the People API fields that should address your needs. We'll shoot you an email when that goes live.

2 reactions Share

Limitations with the write endpoint of the Donations API

The new write endpoint has a few limitations that make it difficult to implement a good external donations solution and track the donations back in Nation Builder:

1) It does not allow donations to be assigned to an existing supporter, but instead creates a new user for every donation. Ideally we'd be able to pass a signup id in the initial payload, which would then assign the donations.

2) We have not been able to write any donation types other than CASH (such as Credit Card), which means they are recorded as "FAILED" and do not show up in reporting.

3) There are no options to write recurring donations and have them show up in /admin/signups/{id}/donations/recurring. This means we cannot effectively build an external recurring donations system and track that back through Nation Builder.

1-2 are priorities for us to be able to effectively use the API for our apps, any idea when these options may be supported?

Official response from

Scott, thanks for your feedback. 1 and 2 sound like possible bugs - can you send us information on which nation you were working on and cURL commands and response bodies for us to review to api@nationbuilder.com? Our bug reporting tips are here

I'm also looking into the feasibility of your request for recurring donations to be handled differently.

3 reactions Share

How to use JSONP with the API?

I'm trying to call the people api through AJAX using jquery but the response doesnt seem to have a callback wrapper, which causes an error. here is some sample code:

function getPeople(){
data = {
"access_token" : token
};
$.ajax({
url: peopleIndexUrl,
type: "GET",
cache: false,
data: data,
dataType: 'jsonp',
success: function(data,textStatus,jqXHR){
console.log(data);
},
error: function(jqXHR,textStatus,errorThrown){
console.log(errorThrown);
}
});
}

 

 The call does seem to go through fine. Perhaps I have to change the callback? Thanks.

Official response from

Eric, JSONP is supported for our API endpoints with the exception of stuff like the /oauth/token endpoint. You should be able to use it with endpoints like /api/v1/people

You also want to wrap your calls in JSONP. So:

https://yournation.nationbuilder.com/api/v1/people.jsonp

not,

https://yournation.nationbuilder.com/api/v1/people

If you continue to run into trouble, you can email us a text file with http request and response samples, using something like www.runscope.com, to api@nationbuilder.com.

1 reaction Share

1  2  Next →
Like this page to spread the word