According to the documentation for the Google Play Developer API, I should be able to batch insert or update requests. However, I’m running into an issue where it appears that either the documentation is wrong, the API is broken, or I’m just missing something.
I’m POSTing to the URL: https://www.googleapis.com/androidpublisher/v2/applications/inappproducts/batch?access_token=<my token here>&autoConvertMissingPrices=true'
MyContent-Typeis set to:application/json
And the body of myPOST` is the following:
{
"entrys": [{
"batchId": "<my batch id>",
"methodName": "update",
"inappproductsupdaterequest": {
"inappproduct": {
"packageName": "<my package name>",
"sku": "<my product sku>",
"status": "active",
"purchaseType": "managedUser",
"defaultPrice": {
"priceMicros": "<my price>",
"currency": "USD"
},
"listings": {
"en-US": {
"title": "<my title> ",
"description": "<my description>"
}
},
"defaultLanguage": "en-US"
}
}
}]
}
When I POST this, I get the following error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter: [entry[0].inappproductsUpdateRequest.package_name]",
"locationType": "parameter",
"location": "[entry[0].inappproductsUpdateRequest.package_name]"
}
],
"code": 400,
"message": "Required parameter: [entry[0].inappproductsUpdateRequest.package_name]"
}
}
If I’m reading this correctly, they want the package name parameter as a child element under inappproductsUpdateRequest. However, when I try moving or copying (tried both) "packageName": "<my package name>" as a child under inappproductsUpdateRequest, I get the error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Unknown field name: packageName",
"locationType": "other",
"location": "entrys.inappproductsupdaterequest"
}
],
"code": 400,
"message": "Unknown field name: packageName"
}
}
I get the same error when I try package_name instead of packageName.
Any thoughts?
Have you tried the requested casing inappproductsUpdateRequest that the response shows? I'm guessing you do need snake case on package_name rather than packageName, but you may need to try both there too.
Related
I have read these documents about create android apps using firebase management api.
https://firebase.google.com/docs/projects/api/reference/rest/v1beta1/projects.androidApps/create
https://firebase.google.com/docs/projects/api/reference/rest/v1beta1/projects.androidApps#AndroidApp
Document doesn't mention which field is required to create app.
After calling below request:
POST v1beta1/projects/sublime-formula-310010/androidApps
{
"displayName": "ggds",
"packageName": "sdf.aw.dsff",
"projectId": "sublime-formula-310010",
"appId": "asdfasdfaewrwe",
"name": "projects/sublime-formula-310010/androidApps/asdfasdfaewrwe"
}
I get below error:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
Any help would be appreciated.
try this:
{
"displayName": "alline",
"packageName": "com.alline.app"
}
I am using the PHP library to use the Android Management API. I can update policies successfully. But I am unable to create a WebToken needed for the Web App iframe.
I have set a credential file.
I do
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope("https://www.googleapis.com/auth/androidmanagement");
$client->setApplicationName("MyAppName");
$androidmanagementService = new Google_Service_AndroidManagement($client);
Then I try to create a WebToken for the request:
$webTokens = $androidmanagementService->enterprises_webTokens;
$webToken = new Google_Service_AndroidManagement_WebToken();
My understanding is that only the ParentFrameUrl and Permissions are needed, everything else will be set in the answer:
$webToken->setPermissions(array("APPROVE_APPS"));
$webToken->setParentFrameUrl("http://37.71.157.174/mdm/");
But I tried also to set the other values:
//$webToken->setName("MyWebAppView");
//$webToken->setValue("98784");
Then I try to create the WebToken :
$webtoken = $webTokens->create("enterprises/entname", $webToken);
And I always get this Google_Service_Exception:
{ "error": { "code": 400, "message": "Invalid parameter: tokenSpec.parent", "errors": [ { "message": "Invalid parameter: tokenSpec.parent", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" } }
The full PHP exception is:
Uncaught Google_Service_Exception: { "error": { "code": 400, "message": "Invalid parameter: tokenSpec.parent", "errors": [ { "message": "Invalid parameter: tokenSpec.parent", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" } } in /var/www/vendor/google/apiclient/src/Google/Http/REST.php:118 Stack trace: #0 /var/www/vendor/google/apiclient/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 /var/www/vendor/google/apiclient/src/Google/Task/Runner.php(176): Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2 /var/www/vendor/google/apiclient/src/Google/Http/REST.php(58): Google_Task_Runner->run() #3 /var/www/vendor/google/apiclient/src/Google/Client.php(798): Google_Http_REST::execute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_ in /var/www/vendor/google/apiclient/src/Google/Http/REST.php on line 118
I have no idea what is wrong. But Everything before the WebToken part work for the other API call.
The URL of the parent frame must use the HTTPS scheme. I think that's the issue you're hitting.
This is mentioned in the documentation of the WebToken resource but it's true that the error message could be clearer.
I am trying to get Id from Youtube API in android app but unable to find
https://www.googleapis.com/youtube/v3/channels?part=id&forUsername={username}&key={YOUR_API_KEY}
But getting this response:
{
"kind": "youtube#channelListResponse",
"etag": "\"sNu6csVZt536JdlmpOxN9WQSd8U/ewwRz0VbTYpp2EGbOkvZ5M_1mbo\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": []
}
I have also tried with this
https://www.googleapis.com/youtube/v3/channels?part=id%2CcontentDetails&mine=true&key={YOUR_API_KEY}
But a response is below:
{
"error": {
"errors": [
{
"domain": "youtube.parameter",
"reason": "authorizationRequired",
"message": "The request uses the \u003ccode\u003emine\u003c/code\u003e parameter but is not properly authorized.",
"locationType": "parameter",
"location": "mine"
}
],
"code": 401,
"message": "The request uses the \u003ccode\u003emine\u003c/code\u003e parameter but is not properly authorized."
}
}
make sure you are logged-in with OAuth when performing these calls and if you're going to parse the JSON response to look for the id, it's found in items.id
Tried this with Channels.list Try-it and I got correct response:
/**
* API response
*/
{
"kind": "youtube#channelListResponse",
"etag": "\"VPWTmrH7dFmi4s1RqrK4tLejnRI/X6OHzHqUUEu1okILXdfdfBbUxU\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"VPWTmrH7dFmi4s1RqrK4tLejfdf/Qw3dXynuD_IdfB1LMKjSeiDI\"",
"id": "UCTjdfopNLdfd5yXVv93Ww"
}
]
}
My request is
`{
"packageName": "com.test.package",
"sku": "title",
"status": "inactive",
"subscriptionPeriod": "P1M",
"purchaseType": "subscription",
"listings": {
"en-US": {
"title": "title",
"description": "title"
}
},
"defaultLanguage": "en-US",
"defaultPrice": {
"priceMicros": "100000000",
"currency": "SGD"
}
}`
to the post call for inserting a product (reference : [https://www.googleapis.com/androidpublisher/v2/applications/packageName/inappproducts]).
Getting error response for this request
`{
"error": {
"errors": [
{
"domain": "androidpublisher",
"reason": "inAppProductRegionsMissingPricing",
"message": "Must provide a price for each region the app has been published in."
}
],
"code": 403,
"message": "Must provide a price for each region the app has been published in."
}
}`
Can anyone explain this error, because i have set a default price ?
And also how do i get all the countries list and its currencies in which the app is published in from google play console ?
Go to PRICING & DISTRIBUTION Page of your app in https://play.google.com/apps/publish/
In Countries find out how many region you have selected for this app.
while inserting the in app product you have provide price for all region you have selected.
so suppose if you have selected Pakistan as region
PK (2 letter ISO country code as key for each price for each region within price array)
then you request should be
{
"packageName": "com.test.package",
"sku": "title",
"status": "inactive",
"subscriptionPeriod": "P1M",
"purchaseType": "subscription",
"listings": {
"en-US": {
"title": "title",
"description": "title"
}
},
"defaultLanguage": "en-US",
"defaultPrice": {
"priceMicros": "100000000",
"currency": "SGD"
},
"prices": {
"PK": {
"priceMicros": "100000000",
"currency": "SGD"
}
}
}
You really don't want to do this, imagine you having to send all that to about 150 countries. You can just parse the ['autoConvertMissingPrices' => true] when inserting or updating a product so Google does the conversion.
In my case here is what I do. { 'autoConvertMissingPrices' => true }
$purchase = $service->inappproducts->update(
'app.package.name',
'product_sku',
$product,
['autoConvertMissingPrices' => true]
);
I was wondering how to get the value of "name" for the following json text with facebook sdk. Assuming I have already got the access token. Any thoughts? Many thanks!
enter code here
{
"id": "100005065353669",
"music": {
"data": [
{
"category": "Musician/band",
"name": "Eason Chan",
"id": "105468519487919",
"created_time": "2013-06-05T20:33:26+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/100005065353669/musiclimit=5000&offset=5000&__after_id=105468519487919"
}
}
}