Java POST request doesn’t send variables

I have a problem. I have the following PHP page:


    header('Content-Type: application/json');
    echo $_POST["agentid"];


And my Java code is the following:

public String callWebpage(String strUrl, HashMap<String, String> data) throws InterruptedException, IOException {

    var objectMapper = new ObjectMapper();
    String requestBody = objectMapper

    URL url = new URL(strUrl);
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    String result = convertInputStreamToString(con.getInputStream());
    return result;

To call the function, I use the following lines:

var values = new HashMap<String, String>() {{
    put("agentid", String.valueOf(agentId));

String jsonResponse = webAPI.callWebpage("", values);

This does print the result of the page, but it gives me:

2021-02-28 00:40:16.735 Custom error: [8] Undefined index: agentid<br>2021-02-28 00:40:16.735 Error on line 5

The page is HTTPS and I do get a response, but why is my agentid variable not getting received by the page and how can I fix this?


Please, consider including the following code in your Java connection setup to indicate that you are POSTing JSON content before writing to the connection output stream:

con.setRequestProperty("Content-Type", "application/json");

In any way, I think the problem is in your PHP code: you are trying to process raw HTTP parameter information while you are receiving a JSON fragment as the request body instead.

In order to access the raw JSON information received in the HTTP request you need something like the following:

// Takes raw data from the request.
$json = file_get_contents('php://input');

// Converts it into a PHP object
$data = json_decode($json);

// Process information
echo $data->agentid; 

Please, see this link and ‘php://input` for more information.

Be aware that with the above-mentioned code you are returning a String to the Java client, although you indicated header('Content-Type: application/json'), maybe it could be the cause of any problem.


“JCenter is at end of life” android lint warning, what is the replacement?

Android Studio Arctic Fox Canary 8 started to warn that JCenter is at end of life

enter image description here

But I cannot just delete jcenter() declarations since it hosts a lot of android artifacts, it would lead to Could not resolve all artifacts error. What is the right way to solve this warning?


There’s a documentation section describing the problem: JCenter deprecation and end of service. You can find the link by expanding the inspection description (Ctrl+F1). The documentation states:

JFrog, the company that maintains the JCenter artifact repository used by many Android projects, recently announced the deprecation and upcoming retirement of JCenter. According to the announcement, JCenter will allow downloads of existing artifacts until February 1, 2022.

Developers who publish artifacts on JCenter should start migrating their packages to a new host, such as Maven Central.

In the near future, we will provide additional information about migrating Android projects away from JCenter on this page.

The expanded inspection description (as well as the documentation above) suggests to replace jcenter() by mavenCentral(). Acually JCenter is a superset of Maven Central, but such a replacement won’t resolve the problem until all JCenter artifacts your project uses will be moved to Maven Central.

I think the optimal solution would be to wait until the libraries you’re using are moved from jcenter() and try to replace it with mavenCentral(). If some artifacts are still missing, take a look at the documentation, may be they are moved into another repository and you should add it to the repositories list as well.

repositories {

//  jcenter()       // <- removed
    mavenCentral()  // <- added

If you’re a library author you should migrate to another repo, probably it would be Maven Central. Note that according to the JCenter deprecation announcement new submissions are allowed only until March 31st 2021.

A few related resources:


Create top-down slide animation using `Transition` from `@headlessui/react` using Tailwind CSS

I want to create the following effect:


Currently, I have this weird effect:

weird animation

I am using Transition from @headlessui/react.

My code looks like:

    show={app.theme !== 'light'}
    enter="transition ease duration-700 transform"
    enterFrom="opacity-0 -translate-y-full"
    enterTo="opacity-100 translate-y-0"
    leave="transition ease duration-1000 transform"
    leaveFrom="opacity-100 translate-y-0"
    leaveTo="opacity-0 -translate-y-full"

How do I achieve it?


I solved it. It doesn’t show the animation on Codesandbox as Tailwind animations don’t work on Codesandbox (it is their bug) but the code is tested locally & it works fine.

{theme.type !== "light" && theme.color !== null && (
        className={`mt-4 mx-2 flex items-center space-x-2 transition-all ease-out duration-700 h-10 ${
            isDarkTheme ? "opacity-100" : "opacity-0"
        <label className="flex items-center justify-between w-1/2 h-full px-4 py-6 text-lg font-medium leading-4 text-gray-400 border-2 border-gray-800 bg-gray-800 rounded-md cursor-pointer">
                className="w-4 h-4"
                checked={theme.color === "dim"}
                onChange={() => {
                        color: "dim",
        <label className="flex items-center justify-between w-1/2 h-full px-4 py-6 text-lg font-medium leading-4 text-gray-400 border-2 border-gray-800 rounded-md cursor-pointer bg-black">
            <span>Lights Out</span>
                className="w-4 h-4"
                checked={theme.color === "lights-out"}
                onChange={() => {
                        color: "lights-out",

Codesandbox →

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..