planningcenter / developers

Planning Center API docs and support
https://developer.planning.center/docs/
85 stars 8 forks source link

Getting a profile joined date #1166

Closed jmezzera closed 5 months ago

jmezzera commented 5 months ago

Related Product Which product is this question related to? People

Describe the question We are developing an internal solution to extract data from your product. We found both the API and the API documentation very helpful for this 🥳. We keep track of the baptism date and join date in a custom tab in the people product (see an example below) Is there a way we can programatically pull these fields?

Thanks in advance

What have you tried that worked?

Using the /people/v2/people endpoint to pull other fields for the users

What have you tried that didn't work?

Reviewing the docs

Additional context

image

I have..

seven1m commented 5 months ago

@jmezzera see if this comment helps: https://github.com/planningcenter/developers/issues/693#issuecomment-552965590

We have some other custom-field questions you might want to browse as well!

jmezzera commented 5 months ago

Awesome, that's a nice pointer. Knowing what to look for is always helpful Let me see if that's enough to solve this issue.

Thanks for the quick response

jmezzera commented 5 months ago

Ok @seven1m, I was able to get the custom field Id, query it for a given profile and get the expected value. Thanks for the pointers, those proved really helpful.

However, I'd like to pull this field for every profile in the system. I'm concerned about API limits. Is there any way I can batch the requests? (ie. given a list of people ids, get a list of responses back)

seven1m commented 5 months ago

Sure, you can change the URL so it isn't scoped by person, like this:

https://api.planningcenteronline.com/people/v2/field_data?where[field_definition_id]=123

jmezzera commented 5 months ago

Wow you are a savior!!

I'm getting a response that contains a list of elements like the one below:

{
      "type": "FieldDatum",
      "id": "<id>",
      "attributes": {
        "file": {
          "url": null
        },
        "file_content_type": null,
        "file_name": null,
        "file_size": null,
        "value": "04/07/2019"
      },
      "relationships": {
        "field_definition": {
          "data": {
            "type": "FieldDefinition",
            "id": "<id>"
          }
        },
        "customizable": {
          "data": {
            "type": "Person",
            "id": "<id>"
          }
        }
      }

Sorry for the dumb question but at this stage I want to be extra cautious: Is it fair to assume that if I get a customizable relationship of type Person, its id will point to a valid Person record?

seven1m commented 5 months ago

Yes, that is correct. I'm closing this issue, but let us know if you have any further questions!

jmezzera commented 5 months ago

Once again, thank you very much for your help!