planningcenter / developers

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

Newb Question - Creating a batch #1168

Closed philfbcnz closed 5 months ago

philfbcnz commented 5 months ago

Which product is this question related to? Giving

Describe the question I am extremely new to API stuff and dev work in general. I am playing around with Postman to learn a few bits and pieces.

Last night I managed to learn and successfully create a donation on a pre-existing batch (gui created) via POST.

But I am struggling to figure out how to POST a batch. I can't get my JSON right. image

Is someone able to provide me with an idea of what the basic raw JSON requirements are to create a new batch via API please?

Thanks! Phil

What have you tried that worked? Nothing, lol.

What have you tried that didn't work?

Additional context

I have..

seven1m commented 5 months ago

I think you're close, but you wrapped the body of your POST in an array instead of an object. So instead of this:

[
  {
    "type": "Batch",
    "attributes": { ... }
  }
]

...you need to do this:

{
  "data": {
    "type": "Batch",
    "attributes": { ... }
  }
}

Hope that helps!

philfbcnz commented 5 months ago

Yay!! Thank you @seven1m , that worked...

{
    "data": {
        "type": "Batch",
        "attributes": {
            "description": "testing"
        },
        "relationships": {
            "batch_group": {
                "data": null
            }
        }
    }
}