JoeBlogs icon indicating copy to clipboard operation
JoeBlogs copied to clipboard

Mapping breaks when wp.getCommentCount returns int if there is a '0' and string if there is an actual number

Open punjabisoul opened this issue 12 years ago • 1 comments

Hi Alex Thanks for writing this awesome API!!

I am trying to download post data from my wordpress blog, but the following happens: Call var commentcount = wordPressWrapper.GetCommentCount(post.PostID.ToString()); in a try/catch block

  • with the current bindings in stuct CommentCount as int and zero comments the code works
  • but when there are comments the binding throws an exception that the response contains string where int is expected.

FIX: Looking at the XML-RPC documentation

  • http://xml-rpc.net/faq/xmlrpcnetfaq-2-5-0.html
    • 1.16 How do I specify data whose type is not known until runtime? it suggests to use System.Object, this works for me.

CHANGE: In the /classes/CommentCount.cs and /xmlRpcStructs/CommentCount.cs change all the types from int to object and then handle actual conversion outside the API i.e. in my project like: commentcount.Approved.ToString()

Hope this helps

punjabisoul avatar Apr 04 '13 16:04 punjabisoul

Hey, If you could do a pull request on this i'll merge it in,

Thanks

alexjamesbrown avatar Apr 15 '13 10:04 alexjamesbrown