I have a client id and client sercet , i want to invoke marketing cloud rest api to get access token

package TestingMC;

import org.apache.http.HttpResponse;
import com.mashape.unirest.http.*;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;

public class RestGetAccessToken {

    public static void main(String[] args) 

        HttpResponse<String> response = Unirest.post("https://auth.exacttargetapis.com/v1/requestToken")
              .header("content-type", "application/json")
              .body("{\n    \"clientId\": \"ycmqXXXXXXXXXX1a3elu\",\n    \"clientSecret\": \"FHXXXXXXXXXXX8l8\"\n}")


However this program is giving error on unirest line

Exception in thread "main" java.lang.Error: Unresolved compilation problem: The type HttpResponse is not generic; it cannot be parameterized with arguments at TestingMC.RestGetAccessToken.main(RestGetAccessToken.java:13)

any clue why


You're using the wrong HttpResponse class. Remove the following line of code from your source:

import org.apache.http.HttpResponse;

And, optionally, add an import for the correct class:

import com.mashape.unirest.http.HttpResponse;

(Since you're using a wildcard import, this is not strictly necessary, but recommended.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.