wp-net / WordPressPCL

This is a portable library for consuimg the WordPress REST-API in (almost) any C# application
MIT License
344 stars 130 forks source link

get null on GetPosts #143

Closed hanniiel closed 6 years ago

hanniiel commented 6 years ago

Hello, I was trying to get posts form my website, and it seems to work on postman and directly putting the web address on browser but I get null on request, no error was shown. I tried different websites and it seems to work just fine but not on this one. any idea why? website: koreaboo I'm using latest version of the PLC Thanks in advance.

polushinmk commented 6 years ago

Hi! Could you share a part of your code? I tried this one and it works fine for me:

var client = new WordPressClient("https://www.koreaboo.com/wp-json/");
var posts = await client.Posts.Get();
hanniiel commented 6 years ago

@polushinmk sure, it was my mistake I didn't specify i was using the query builder, the problem happens when I set embed to true. :(

code

var queryBuilder = new PostsQueryBuilder(); queryBuilder.PerPage = 8; queryBuilder.Page = page; queryBuilder.Embed = true; //queryBuilder.Categories = new int[] { 1, 2, 3 }; try { var response = await client.Posts.Query(queryBuilder); return response; } catch (Exception e) { var m = e.Message; return null;
}

code

ThomasPe commented 6 years ago

I've just merged the PR and updated the package (should be available on NuGet soon)

hanniiel commented 6 years ago

I've just merged the PR and updated the package (should be available on NuGet soon)

Thank you so much :) I just tried it and I've got the following: Error converting value "artist" to type 'WordPressPCL.Models.TermTaxonomy'. Path '[0]._embedded.wp:term[3][0].taxonomy', line 1, position 10101. any idea why this happened ? thanks in advance, and I'm sorry 4 bothering that much :,(.

I'd also like to know what parts of code do I have to modify to adapt it if this is the case. Best regards

hanniiel commented 6 years ago

I've just merged the PR and updated the package (should be available on NuGet soon)

Thank you so much :) I just tried it and I've got the following: Error converting value "artist" to type 'WordPressPCL.Models.TermTaxonomy'. Path '[0]._embedded.wp:term[3][0].taxonomy', line 1, position 10101. any idea why this happened ? thanks in advance, and I'm sorry 4 bothering that much :,(.

I'd also like to know what parts of code do I have to modify to adapt it if this is the case. Best regards

The full request is: https://www.koreaboo.com/wp-json/wp/v2/posts?_embed=true seems like it's a problem related to yoast, the full json request is:

I think, this part is kinda the problem: "yst_prominent_words":[],"artist":[],"series":[],"collection":[]," best regards

Code `[{"id":410554,"date":"2018-10-28T22:00:12","date_gmt":"2018-10-29T05:00:12","guid":{"rendered":"https:\/\/www.koreaboo.com\/?p=410554"},"modified":"2018-10-28T22:10:03","modified_gmt":"2018-10-29T05:10:03","slug":"yg-artists-cannot-just-make-comebacks-seungri-explains","status":"publish","type":"post","link":"https:\/\/www.koreaboo.com\/stories\/yg-artists-cannot-just-make-comebacks-seungri-explains\/","title":{"rendered":"YG Artists Can’t Just Make Comebacks, Seungri Explains Why It Takes So Long"},"content":{"rendered":"

Seungri recently appeared on\u00a0AKMU Suhyun’s Volume Up\u00a0<\/em>and revealed the reason why YG Entertainment’s artists take so long with their comebacks.<\/p>\n

\"seungri1\"<\/p>\n

 <\/p>\n

Seungri explained that YG Entertainment did not just produce albums and do everything for their artists but that the artists had to work hard themselves in order to make a comeback.<\/p>\n

“You (Suhyun) also probably know but YG is not a company that produces albums and makes your schedule when you’re just sitting around doing nothing. The artists have to take initiative. Or else it could take a year or even 3 years.” \u3161\u00a0Seungri<\/strong><\/p><\/blockquote>\n

 <\/p>\n

Fans have frequently complained in the past that YG Entertainment wasn’t giving enough attention to their artists as it often takes awhile for artists to make a comeback. Until BLACKPINK’s recent comeback, fans were getting extremely antsy as it had already been a year since BLACKPINK’s last album.<\/p>\n

\n

YG is a piece of shit you literally gave blackpink a few weeks to prepare for this comeback.. YOU HAD A WHOLE YEAR and what did you do? nothing<\/p>\n

— \ud83d\udda4 (@jypehirai) June 16, 2018<\/a><\/p><\/blockquote>\n

Githubissues.

  • Githubissues is a development platform for aggregating issues.