erickok / retrofit-xmlrpc

Typed XML-RPC support for Retrofit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Params are void

atlantis210 opened this issue · comments

Hello,

I'm trying to use your library with Kotlin/Retrofit and RxAndroid but I do not succeed in putting params into the request. It is as if the PostsArgs were not used/read. Do you have any idea what I could miss ?

Thanks

Little update:
ApiAccess is the class I'm trying to pass:

class ApiAccess {
    companion object {
        @JvmField
        val username : String = "blog@bla.com"
        @JvmField
        val password : String = "pwd"
    }
}

When I try to pass

@XmlRpc("wp.getUsersBlogs") @POST("/xmlrpc.php")
fun getBlogApiAccess(@Body args: ApiAccess): Observable<ArticleModel>

it doesn't work, params are empty
but when I do

@XmlRpc("wp.getUsersBlogs") @POST("/xmlrpc.php")
fun getBlogApiAccess(@Body args: String): Observable<ArticleModel>

and I pass "test" as a param, it is well present in params request

Do I have to tell ApiAccess class is Serializable or something ?

No, it does not have to be Serializable. Hm weird. I even tested against the Wordpress XML-RPC interface some times: https://github.com/erickok/retrofit-xmlrpc/blob/master/xmlrpc/src/test/java/nl/nl2312/xmlrpc/WordpressIntegrationTest.java Could you run that example test and see if it works? Otherwise, is this also for builds where you don't use Proguard?

I tried and here is the result :

java.lang.RuntimeException: blogId could not be accessed to read XML-RPC param

I'm using this version of your lib : implementation 'com.github.erickok:retrofit-xmlrpc:v1.2'
I don't use Proguard for now since this is just in debug for now

Edit: I passed the class and field to public and it worked. I will try to use it with kotlin now
I passed it in kotlin and it does not work neither with companion object nor object

Well, I used Java class to send the request then. But it's weird with kotlin file it does not work. You can either close this issue or try to fix it, your choice :p
Anyway, thanks for you reactivity and your lib ;)

Last thing ! Is there a way to order the params as you wish ? The params are put weirdly in my request

Alright so it works with Java, not with Kotlin. Can you show the code you used for the Kotlin class? Kotlin's properties are automatically rewritten to getters/setters by default.

Edit: I see you updated your comment. It looks liek you are using static fields (since they are in a companion object). Static fields would be ignored. Why did you add them to the companion class?

If not, itwould say:

java.lang.RuntimeException: username could not be accessed to read XML-RPC param

Hi,
I found out how to do it with Kotlin files !
class PostsArgs(@JvmField val username: String, @JvmField val password: String)
I think you could add it in your readme for others ;)
Anyway, thanks a lot for your time and library :)
See ya

Yes, that's the correct way to do JVM fields in Kotlin. Glad it works now!

Yep but I didn't know static fields were not taken into account ;)

And there is no way to know how the parameters are going to be written in the request ? Because here is my PostsArgs
class PostsArgs(@JvmField val username: String, @JvmField val password: String, @JvmField val postStatus: String, @JvmField val number: Int, @JvmField val offset: Int)

and my request

   <methodName>wp.getUsersBlogs</methodName>
   <params>
      <param>
         <value>
            <i4>5</i4>
         </value>
      </param>
      <param>
         <value>
            <i4>1</i4>
         </value>
      </param>
      <param>
         <value>
            <string>password</string>
         </value>
      </param>
      <param>
         <value>
            <string>publish</string>
         </value>
      </param>
      <param>
         <value>
            <string>login</string>
         </value>
      </param>
   </params>
</methodCall>

Therefore, the answer from the server is : bad username or password... :/

Nevermind.... It is taken alphabetically with the name of the parameter. Thanks again