Search code examples
androidweb-servicesintform-data

How to pass long or int data type value in MultipartEntity?


I'm developing web-serviced base app, and my web-service requirement is pass int or long value in form data in parameter. Is it possible or not?

Here is my code:

MultipartEntity entity  = new MultipartEntity(
            HttpMultipartMode.BROWSER_COMPATIBLE);

entity.addPart("key_id", new StringBody("10001")); //pass int or long

What should I use instead of new StringBody("0").


Solution

  • As far as I know, MultipartEntity.addPart() accepts only StringBody or FileBody.

    Anything else has to be converted to String and type-casted again in receiver side, in this case Long/Int.