Search code examples
androidandroid-management-api

Get back json response from android management API call


I am using android management api in my android application. Now I want to get the policies of my android app I am using this method policies.get for fetching the policy. Now what i want is acually to get the json from response back in my application. This is how i did

checkPolicy(ENTERPRISE_ID,name);


 private void checkPolicy(String enterpriseName, String policyId)
            throws IOException {
        System.out.println("Getting policy...");
        String name = enterpriseName + "/policies/" + policyId;
          androidManagementClient
                .enterprises()
                .policies()
                .get(name)
                .execute();

    }

Here I am using correct way to get the policy but i don't know how get reponse back? I mean like in this page. I enter the parameters and recieve a json. Now what i need to do in application to get response json


Solution

  • Your request should be in the form enterprises/{enterpriseId}/policies/{policyId}

    And you can save the response into a variable :

     var policyJson = androidManagementClient
                    .enterprises()
                    .policies()
                    .get(name)
                    .execute();