Yelp Fusion POST请求

时间:2017-06-18 06:44:07

标签: java http yelp

我正在尝试获取使用Yelp Fusion API的访问令牌。我尝试在下面发出以下POST请求,但一直收到404错误。这是我第一次尝试发出POST请求,所以我不确定我是否做得对。

我在这里附上了YELP的说明:https://www.yelp.com/developers/documentation/v3/authentication

提前致谢。

public static final String YELPURL = "https://api.yelp.com/oauth/token";
public static void main(String[] args) {
    try {
        URL obj = new URL(YELPURL);
        HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("grant_type", "client_credentials");
        con.setRequestProperty("client_id", CLIENTID);
        con.setRequestProperty("client_secret", CLIENTSECRET);
        con.setDoOutput(true);
        int responseCode = con.getResponseCode();
        System.out.println("Response Code: " + responseCode);   
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

1 个答案:

答案 0 :(得分:0)

重新阅读您发送的链接

您应该发送到https://api.yelp.com/oauth2/token

而不是https://api.yelp.com/oauth/token