Pods plugin api return false when there are no images to return. How to change it?

I’m using pods plugin for creating custom post types and I have created a form to add multiple images/media/attachments to a post. API returns all the required data when there are media to be returned as a array list. But it returns “false” when there is no images or media or attachments already uploaded to this custom post. I’m using spring boot to get data from the wp rest api and as the api returns “false” instead of returning an empty array when there are no images, and the POJO throws exceptions due to that. How can I return a empty array instead of false here??

below is the json recieved when there are no images or videos or attachments are uploaded to the post. When there are uploads, It will return a json array.

{
“id”: 918,
“date”: “2018-10-05T11:06:17”,
“date_gmt”: “2018-10-05T11:06:17”,
“guid”: {
“rendered”: “http://localhost:8090/index.php/news/ncell-handovers-cash-prize-under-recharge-and-win-offer4th-week-winners-receive-rs-100000-each/”
},
“modified”: “2018-10-05T11:06:17”,
“modified_gmt”: “2018-10-05T11:06:17”,
“slug”: “ncell-handovers-cash-prize-under-recharge-and-win-offer4th-week-winners-receive-rs-100000-each”,
“status”: “publish”,
“type”: “news”,
“link”: “http://localhost:8090/index.php/news/”,
“title”: {
“rendered”: “hello world”
},
“content”: {
“rendered”: “”,
“protected”: false
},
“author”: 1,
“template”: “”,
“categories”: [
49
],
“summary”: “”,
“images”: false,
“videos”: false,
“attachments”: false,
“_links”: {
“self”: [
{
“href”: “http://localhost:8090/index.php/wp-json/wp/v2/news/918”
}
],
“collection”: [
{
“href”: “http://localhost:8090/index.php/wp-json/wp/v2/news”
}
],
“about”: [
{
“href”: “http://localhost:8090/index.php/wp-json/wp/v2/types/news”
}
],
“author”: [
{
“embeddable”: true,
“href”: “http://localhost:8090/index.php/wp-json/wp/v2/users/1”
}
],
“version-history”: [
{
“count”: 0,
“href”: “http://localhost:8090/index.php/wp-json/wp/v2/news/918/revisions”
}
],
“wp:attachment”: [
{
“href”: “http://localhost:8090/index.php/wp-json/wp/v2/media?parent=918”
}
],
“wp:term”: [
{
“taxonomy”: “news_categories”,
“embeddable”: true,
“href”: “http://localhost:8090/index.php/wp-json/wp/v2/categories?post=918”
}
],
“curies”: [
{
“name”: “wp”,
“href”: “https://api.w.org/{rel}”,
“templated”: true
}
]
}
}

Read more here:: Pods plugin api return false when there are no images to return. How to change it?

Leave a Reply

Your email address will not be published. Required fields are marked *