I’m trying to retrieve posts from our creator account using the following endpoint:
https://www.patreon.com/api/oauth2/v2/posts/<post_id>
This works fine and I get the following payload:
{
"data" : {
"attributes" : {},
"id" : "<post_id>",
"type" : "post"
},
"links" : {
"self" : "https://www.patreon.com/api/oauth2/v2/posts/<post_id>"
}
}
The problem is when I try to get other fields from this endpoint. Since the documentation is lacking, I’m basing my requests on the code I see in the WordPress plug-in. In patreon_api_v2.php
, the get_post
function shows that the fields are specified as:
fields[post]=title,content,is_paid,is_public,published_at,url,embed_data,embed_url,app_id,app_status
I’m URL encoding these parameters before adding them to the query string, but I’m still getting the bare payload without any title or content.
Am I doing something wrong here or is this API not working correctly?
-ch
Can you post your exact call? You could also get all those as an include while querying posts endpoint to get the list of posts/
Here is the command I’m using with curl
:
curl --request GET --url https://www.patreon.com/api/oauth2/v2/posts/<post_id>?fields%5Bpost%5D%3Dtitle%2Ccontent%2Cis_paid%2Cis_public%2Cpublished_at%2Curl%2Cembed_data%2Cembed_url%2Capp_id%2Capp_status --header 'authorization: Bearer REDACTED'
The requested post was created by the user account used to create the Bearer token.
I also tried your suggestion of using an include parameter, but get an error when I try to use things like “post”, “campaign.posts”, “title”, etc.:
curl --request GET --url https://www.patreon.com/api/oauth2/v2/campaigns/<campaign_id>/posts?include=post --header 'authorization: Bearer REDACTED'
{
"errors" : [
{
"code" : 1,
"code_name" : "ParameterInvalidOnType",
"detail" : "Invalid parameter for 'include' on type post: ['post'].",
"id" : "eb075c1c-7386-54ba-b2f7-b053e8786c5a",
"status" : "400",
"title" : "Invalid value for parameter 'include'."
}
]
}
Still stumped.
-ch
I’m an idiot. I was URL encoding the “=” in the query string.
For anyone that stumbles across this thread, use a curl
command like this:
curl --request GET --url 'https://www.patreon.com/api/oauth2/v2/posts/<post_id>?fields%5Bpost%5D=title%2Ccontent%2Cis_paid%2Cis_public%2Cpublished_at%2Curl%2Cembed_data%2Cembed_url%2Capp_id%2Capp_status' --header 'authorization: Bearer REDACTED'
-ch
1 Like
While I have your attention @codebard - is there a way to get the uploads and tags associated with the post?
-ch
Currently the api does not support attachments and tags, so no. It may be a good addition though.
1 Like