Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Contributor via API #1440

Open
Simon1050 opened this issue Feb 28, 2024 · 4 comments
Open

Add Contributor via API #1440

Simon1050 opened this issue Feb 28, 2024 · 4 comments

Comments

@Simon1050
Copy link

Hey there,
I have a question. I am using the podlove-api (podlove version 4.0.13) to edit an episode on wordpress. But I do not understand how to add a contributor to the episode.
I have tried the endpoints /wp-json/podlove/v2/episodes/72/contributions and /wp-json/podlove/v2/episodes/contributions/72 with
{ "contributor_id": 1, "role_id": 1, "group_id": 1, "position": 0, "comment": "Host of the episode." }
as body, but no contributors were added.

Can somebody tell me, how this is done correctly?

Simon

@dnkbln
Copy link
Contributor

dnkbln commented Feb 29, 2024

Hello Simon,
if you use the endpoint /wp-json/podlove/v2/episode/{episode_id}/contributions the input is a array of contributor. The payload should be

{
    "contributors": [
        {
            "contributor_id": 1,
            "role_id": 1,
            "group_id": 1,
            "position": 10,
            "comment": "Moderator"
        }
    ]
}

If you have more the one Contributor, you can add more objects to the array. But with this method the existing episode contributions will be delete before we add the new ones.

If you use the endpoint /wp-json/podlove/v2/episode/contributions/{id}. The id doesn't mean the episode_id. It means a episode_contributions_id.

GET /wp-json/podlove/v2/episode/{episode_id}/contributions has following result

{
    "_version": "v2",
    "contribution": [
        {
            "id": "371", <---- this is the episode contribution id
            "contributor_id": "1",
            "role_id": "1",
            "group_id": 0,
            "position": "10",
            "comment": "Moderator",
            "default_contributor": true
        }
    ]
}

I hope that helps you.
Dirk

@Simon1050
Copy link
Author

Hi Dirk,
sorry for my late answer.

I have tried to add this contributor

{
    "contributors": [
        {
            "contributor_id": 44,
            "role_id": 0,
            "group_id": 0,
            "position": "0",
            "comment": "Test"
        }
    ]
}

by posting to wp-json/podlove/v2/episodes/361/contributions.

But if I try to control this, I only get this result from wp-json/podlove/v2/episodes/361/contributions

{
    "_version": "v2",
    "contribution": [
        {
            "id": "578",
            "contributor_id": null,
            "role_id": 0,
            "group_id": 0,
            "position": null,
            "comment": "",
            "default_contributor": false
        }
    ]
}

from a get request.

On the webpage is shown an empty contributor:

Screenshot 2024-04-14 143816

Do you have any other ideas what I am doing wrong?

Simon

@dnkbln
Copy link
Contributor

dnkbln commented Apr 14, 2024

Could you please check if the contributor_id 44 is existing. The route wp-json/podlove/v2/contributors deliver a list of the existing contributors. If you aren't authenticate you will get only public contributors.

May I should improve the API. If the contributor_id not exist i should return with an error.

@Simon1050
Copy link
Author

That would be great. And thank You. Now it is working when I post to /wp-json/podlove/v2/episodes/{id}/contributions and then to /wp-json/podlove/v2/episodes/contributions/{id} with the returned contribution id from first request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants