How to send POST data to a server. in kotlin

0

My question is how can I send certain parameters that have to go back to the server if the event is done on

  

val store_id = 5463       val option = playsong       val play_now = true       val song_id = 163309

     

These are data that I have to return if the event is done on click and I have to do it by POST and JSON method. It should be noted that the data I receive comes from the same server and I visualize it in a recyclerview

  @SuppressLint("Registered")
    class VolleySingleton : Application(){
        override fun onCreate() {
            super.onCreate()
            instance = this
        }
        val requestQueue: RequestQueue? = null
            get() {
                if (field == null){
                    return Volley.newRequestQueue(applicationContext)
                }
                return field
            }

        fun <T> addToRequestQueue(request: Request<T>) {
            request.tag = TAG
            requestQueue?.add(request)
        }

        companion object {
            private val TAG = VolleySingleton::class.java.simpleName
            var instance: VolleySingleton? = null
        }

    } 

this is what I have been without success

    
asked by Francisco Navarrete 27.03.2018 в 02:20
source

1 answer

0
  try {
                Fuel.post("https://api.ejemplo.com/?option=algo", listOf("option" to "playsong", "store_id" to "1",  "play_now" to "true", "song_id" to developersList.song_id)).responseJson { request, response, result ->
                    val Bazinga = result.get().content

                    Log.e(TAG, "MENSAJE:  " + Bazinga)
                }
            } catch (e: Exception) {
                val Bazilon = e.message
                Log.i(TAG,"ERROR:  " + Bazilon)
            }

This is the answer

    
answered by 28.03.2018 в 22:15