Dave's Brain

Browse - Programming Tips - How do I made the body for an HTTP POST that is url-encoded?

Date: 2014jan29
Language: Java
OS: Android

Q.  How do I made the body for an HTTP POST that is url-encoded?

A.

import android.net.Uri.Builder; ... Builder builder = new Uri.Builder(); builder.appendQueryParameter("param1", param1); builder.appendQueryParameter("param2", param2); builder.appendQueryParameter("param3", param3); String data = builder.build().toString(); if (data.startsWith("?")) { data = data.substring(1); } // Now you can use "data" as the body of a POST

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.