0
下面是我的代碼:谷歌播放API返回「400錯誤的請求」
public class MyTestCase {
private static final Log log = LogFactory.getLog(ListApks.class);
public static void main(String[] args) {
try {
Preconditions.checkArgument(!Strings.isNullOrEmpty(ApplicationConfig.PACKAGE_NAME),
"ApplicationConfig.PACKAGE_NAME cannot be null or empty!");
// Create the API service.
final AndroidPublisher service = AndroidPublisherHelper.init(
ApplicationConfig.APPLICATION_NAME, ApplicationConfig.SERVICE_ACCOUNT_EMAIL);
final AndroidPublisher.Edits edits = service.edits();
// Create a new edit to make changes.
AndroidPublisher.Edits.Insert editRequest = edits
.insert(ApplicationConfig.PACKAGE_NAME,
null /** no content */);
AppEdit appEdit = editRequest.execute();
Get purchases = service.purchases().products().get(ApplicationConfig.PACKAGE_NAME, "consumer", "bg46378");
System.out.println(purchases);
ProductPurchase purchase = purchases.execute();
} catch (IOException | GeneralSecurityException ex) {
log.error("Exception was thrown while updating listing", ex);
}
}
}
問題是,我不斷收到:
SEVERE: Exception was thrown while updating listing
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid Value",
"reason" : "invalid"
} ],
"message" : "Invalid Value"
}
我不太知道這有什麼關係與令牌參數(我將在稍後使用的有效載荷)。
編輯:我意識到我需要把purchaseToken放入GET的token參數。 purchaseToken來自移動客戶端的有效載荷。但我仍然得到相同的結果。我放入的purchaseToken看起來像
String pt = "amopiilkhbjihjkfpbobeimo.AO-J1OzmDyihgfHLIPzDWfacU6EVf3rCj7LCbfypeO066DXddCoMgX7UeHesl32HA4K_x6rkYDEMR1e4rfhCYEMcc_8Xx_eySLIZ6BejrH8eJyZ0IhVREa0";
有人嗎?我一直堅持到我能解決這個問題。我已經嘗試了一切從指令,但仍然得到這個錯誤。只是一個標準的程序,所以我無法弄清楚。 –